Thursday 20 August 2009

Trying to figure out why php headers not working on 404 page

This morning I tried to change my site config for the domain I use to access phpMyAdmin so that it would restrict access based on ip address range, as well as basic auth asking for a username and password (and then of course phpMyAdmin also requires a username and password to log in).

However, NginX uses the CIDR notation for specifying an ip address range, and although I read the Wikipedia article on CIDR, I couldn't really get my head round it, so I asked on the web squeeze if someone could tell me the correct value to put on the end to cover the ip address range I needed.

After that, I stopped MySQL listening on a port by using the skip-networking option in my.cnf. Not listening on ports when all connections are local is 'Highly Recommended' by MySQL.

Then I checked my email, which took quite a while.

Some useful webpages I've used recently:
Optimizing FastCGI performance
PHP on Fire: Five Opcode Caches compared
Benchmarking Drupal with PHP op-code caches: APC, eAccelerator and XCache compared
Alternative PHP Cache (APC)

The reason I decided to use APC as opposed to XCache or eAccelerator is that APC has some of the PHP developers working on it, so it seems that it will likely be more compatible with PHP and have less problems (though I have read reports of problems from users of all 3 opcode caches). It also seems that the performance difference between the 3 programs isn't very great.

After lunch I went on Animal Crossing, then I tried to get my photosite working again on my local PC. Since I had changed my file structure to match the web server, it needed a few bits changing to make it work again.

Then I tried the latest ImageMagick to see if it had fixed the problem of corrupting XMP. It seems it has been fixed, at least partially, though I still couldn't write an exif tag to the converted file using exiftool (not that I actually need to be able to do that).

After that I discovered that my 404 error page wasn't redirecting to the old website when a page from the old website was requested, but was just displaying a blank page instead. Try as I might, I couldn't get the 404 page to redirect to the correct page, and I couldn't work out how to write an equivalent rule in Nginx either.

The page works fine in my local environment, running on Apache, but not on the web server under Nginx. When I checked the headers being sent by the page, I could see the Location header had been sent (though the page wasn't actually re-directed), and the 301 redirect header didn't seem to be sent, just the 404 header (which I presume Nginx sends). I will try and set up a simple test on the server tomorrow to see if it works or not.

In the evening I also finished watching Thunderball with Moccle and L, and watched 'Tom Brown's School days', which has Stephen Fry in it, but weirdly he doesn't use an Apple Macbook to Tweet on Twitter in it at all!

Food
Breakfast: Lemon marmalade toast sandwich; cup o' tea.
Lunch: BLT; Piece of (cold) Lemon Meringue pie; Nectarine; Time out (single); cup o' tea.
Dinner: Cottage pie; tomato ketchup; peas. Pudding was a Chocolate Chip Snackie bar. Coffee.

No comments: