Thursday, 18 June 2009

Watching skilk 103.2 stooef

This mroning I checked my email, and then carried on with with getting Nginx, php-fcgi and spawn-fcgi set up.

I moved my server (virtualhost) configuration into a seperate file in a 'sites' directory, and then told Nginx to include all files in the sites directory. However, after making some more changes to the .conf files, I got the following error when trying to start Nginx:

Starting nginx: 2009/06/18 05:14:49 [warn] 22752#0: conflicting server name "mywebsite.com" on 0.0.0.0:port, ignored
2009/06/18 05:14:49 [emerg] 22752#0: could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32
[FAILED]


After some messing about I discovered what had happened - I had been editing the site config file locally, and then uploaded the 'sites' folder to Nginx's conf directory. The sites directory that I uploaded included the previously saved version of my site config file (so it contained photosite.conf and photosite.conf~). Because I had just uploaded the directory, I hadn't noticed the extra file. So of course, Nginx was trying to load the site info from both files, which was breaking it.

After that I tried to copy one of my apache rewrite directives to Nginx, just a simple one that redirects page to page.php:
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,QSA,L]

However, I had some trouble with this as Nginx didn't like me have a nested if statement to check both RewriteConds. Luckily I found this website that describes the problem and how to get round it: Nginx Hacking Tips.

Then I tried to get Nginx working on my main domain, as previously I had just been testing it on a subdomain. However, when I tried this I got the error
2009/06/18 06:18:58 [emerg] 1690#0: could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32
2009/06/18 06:18:58 [emerg] 1690#0: the configuration file /home/mysite/nginx/conf/nginx.conf test failed
The answer was to set
server_names_hash_bucket_size 1024;
in the http section of nginx.conf.


After lunch I played on Animal Crossing for a while, then carried on getting Nginx, php-fcgi and spawn-fcgi set up. When I tried to access my website, I found that PHP couldn't find any of the includes files that were beneath the site's root directory. So I edited php.ini and added the correct path to the include_path value. However, I was still getting the same problem.

I retarted Nginx, but PHP still couldn't find the includes files. I tried checking the phpinfo() page, and it didn't show the correct include_path that I had added to php.ini. I tried clearing my cache and refreshing the page, but it seemed that the php.ini file just wasn't being loaded. I checked the php.ini file on the server did have the include_path directive, and it did.

Then I remembered that the PHP process is actually managed by spawn-fcgi, not Nginx. So I restarted spawn-fcgi, and the php.ini file loaded okay. Yay!

The next problem I had was that files from my static subdomain were just giving a 403 Forbidden error. After some playing around and checking the logs, I found this was because I restricting access to my site by ip address, and that I needed to add the local loopback address as okay as well:
allow my.ip.address;
allow 127.0.0.1;
deny all;


After I'd got nginx, php-fcgi and spawn-fcgi seemingly up and working okay (though it did seem a bit slow), I checked my spleenmail. Then I wondered if it was possibly to do Client Side Includes so parts of a page could be loaded from a user's cache, in the same way that images, CSS and javascript are. I would have thought this should give a decent speed improvement as the Server would only have to process the CSI file once, and the client would only have download the CSI file once, no matter how many pages in the site they visit.

Googling for "Client Side Includes", I found quite a lot of info, though all the suggestion seemed to just be using javascript to insert the CSI. However, then I found this thread: [whatwg] Client-side includes proposal, which is a suggestion for having Client Side Includes in HTML5. Unfortunately reading that thread, and also What’s not in HTML 5? it seems unlikely that Client Sides Includes will make it into HTML5.

Most of the reasons against Client Side Includes seem to be that you can use Server Side Includes. However, if you're serving up a large hierarchical menu, then surely it would be much better to serve this once than with every pageview. The other alternative in this case would be to serve only one level of the menu at a time, and then get each sublevel of the menu as needed via AJAX. However, this would be far slower, slows the server down with even more HTTP requests, and non javascript users would need to reload the whole page each time they want to drill down a level in the menu.

I tried the following Client Side Include Methods:
<h2>Link</h2>
<link rel="html" type="text/html" href="/CSITest.html" />

<h2>Object</h2>
<object data="http://photosite.com/CSITest.html" type="text/html" width="200" height="100"></object>

<h2>XInclude</h2>
<div xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="http://photosite.com/CSITest.xml"/>
</div>
But only Object worked, and that didn't work in a suitable manner, it was just the same as an iframe.

After dinner I watched an episode of Fishing with John and an episode of Satr Trk with Moccle and Lad. Then I tried to solve a problem with some CSS on my website, but couldn't, so posted to the Web squeeze to see if anyone could help me.

Then I watched Transporter 3 with Moccle, which was quite good, but had some rubbish 'romantic' scenes, which were boring. Plus the woman in it was quite annoying, and Jason Statham didn't punch her :(

The weather today was overcast all day except about an hour before sunset. I'm not sure if sunset was visible or not, as it seemed to cloud over again around sunset. It was very windy as well.

Food
Breakfast: Strawberry jam toast sandwich; cup o' tea.
Lunch: 2x cheese on toasts; salad; Plum; 3x cherries; Slice of Fabulous Bakin' Boys' Raspberry flavour flapjack; Orange Trophy; cup o' tea.
Dinner: Beef burger with processed cheese slice, tomato ketchup and salad in a bun; bowl of cream of vegetable soup; bun. Pudding was a small slice of Strawberry flan and a cherry bakewell. Coffee.
Supper: Choc chip cookie; fly biscuit; cup o' tea.

No comments: