Wednesday, 7 December 2011

Setting up wordpress mu under apache

This morning I was still trying to get my wordpress multisite setup in my local dev environment on apache. The first problem I had was that I am using two variations of each domain - domain.con for nginx and domain.can for acessing the same site through apache. Because wordpress gets the domain name from the db (and wp_config) and checks it against the request, this meant I needed to have a separate db for .can and .con and also make some modifications to wp_config.

Otherwise if the db was for .con domains and I requested domain.can, wordpress would redirect me to .con. After getting this setup, I tried logging into the wp-admin area via the .con (nginx served) domain, but just got a couple of error messages about missing indexes in arrays etc. from some plugins. Doing some debugging I eventually tracked the problem down to wp_redirect. The function sends a redirect header, but this header wasn't being received according to the Web Developer toolbar in Firefox.

I scratched my head for a while, then tried turning off WP_DEBUG in wp_config. (I needed it switched on yesterday as otherwise wordpress just displayed a blank page instead of giving an error message about the mysql extension being missing). With WP_DEBUG set to false, the admin area now loaded successfully. Of course, now I thought about it, it was obvious why the header wasn't working - PHP had already sent output in the form of the error messages to do with the badly written plugins, and so couldn't send any headers.

It's a shame that PHP didn't also give the standard error message of 'Headers already sent' as that would have made debugging the issue much easier and quicker. Maybe that error message needs a stricter error reporting setting than wordpress uses with WP_DEBUG switched on.

The next job was to figure out why w3totalcache was correctly serving images from a static subdomain for the .con nginx site but not the .can apache site. I found the problem was that it loads the configuration settings from a file (rather than, or maybe as well as the database). After some debugging, I found the configuration file is stored as '/wp-content/w3-total-cache-config-domain.con.php' (I spent quite a while looking in the plugin directory as I thought it would save its files in there). So I just copied that file, renamed it to '/wp-content/w3-total-cache-config-domain.can.php and replaced the references in it to domain.con with domain.can.

Tuesday, 6 December 2011

websiting

This morning I wrote a blog post for my web development blog about using .htaccess to make a browser download an image from a link instead of just opening the image in the browser.

I noticed that the favicon for the blog was the same as the one for my photo tips website, so I thought I'd better change that. Looking into that, I found that I didn't have a full copy of my wordpress multisite in my dev (virtual) machine. So I downloaded the files that looked to be missing from the server, and updated the local database with a copy from the server.

Then I found that my recipes website wasn't working properly on my local machine. I checked up what the problem was, and I was missing a rewrite rule. The webserver my wordpress multisite is on uses apache, while my local dev environment uses nginx, so I had to have a few tries before I got the rule working properly. Then I thought about what the rule was doing, and it was sending requests for static images to a PHP page that would then serve the image file. Not good!

To do some testing on getting it working properly I really needed to get apache working in my local setup, so I spent quite a bit of time working on this.

Most of the evening I was trying to work out why PHP wasn't loading any extensions. In the end I worked out the problem was that my php.ini file has [HOST] and [PATH] sections in it. After loading my php.ini file PHP would then go onto load other configuration .ini files that loaded mysql and the other extensions. But because they were below a [HOST] section, the directives in the other .ini files were only being applied for that host, and not globally. The fix was at the bottom of my php.ini file to put [PHP]. That switched it back to the global section, so directives in the other .ini files to load the extensions were treated globally (or at least not ignored).

I still have quite a bit of work to do to get PHP and apache working properly together and my wordpress multisite running it looks like though.

Monday, 5 December 2011

Various

This morning I was going through some old emails that I hadn't had time to check properly, and one was from 7dayshop for an interesting gadget - Capture Camera Clip Strap/Belt System by Peak Design (affiliate link). It's basically a quick release system that you can attach to your belt or bag strap. Initially I thought this wouldn't be that great since if you wanted to mount the camera on a tripod or monopod, you'd have to remove the proprietary quick release plate and then attach a QR plate compatible with your tripod / monopod head. This would be a hassle and take too long.

But actually, according to their video, the proprietary QR plate they use is arca-swiss compatible. Since I use arca-swiss compatible QR clamps on all my tripod heads, this would mean the camera could be used on a tripod or monopod with no hassle at all. However, £50 seems extremely expensive to me, I might consider one if they were £20, and would probably buy one if it was £10. Having my camera on a strap as I do now is not much inconvenience compared to putting it on a belt clip, so not worth the price for me.

Most of the afternoon and some of the evening I worked on an article for my photo tips website. Also in the evening I played on Kirby Wii with L and Mauser, and did some work trying to make a file download prompt in .htaccess

Sunday, 4 December 2011

Various

This morning I started cutting out some pogs in Photoshop, then went to Church. After church I started updating my pog website, then had dinner. After dinner I finished updating the pog website. I made a cake in the afternoon and also played on Kirby Wii with L and Mauser a bit. In the evening I copied all the transcripts of Widmore talking from Lostopedia.

Saturday, 3 December 2011

Walking

I forgot to post a pic of these Intel sweets Mauser got from work a few weeks ago:

After copying those pics across to my comp, and writing yesterday's blog post, I went out for walk as it was nice weather. I stopped to take some test shots not too far from the house, and then realised that I needed another adapter ring to be able to some of my srew-in filters with my Cokin P filters as well.

So I went back home, then as it was only about 1½ hrs until lunch, I decided to make some cake. But I remembered that actually I needed to leave the fruit soaking overnight, so I couldn't make the cake now. So I made some cheese straws instead.

After lunch I went out for another walk, this time making sure I brought the other adapter ring I needed. Part of the walk was a bit scary as I had to walk through a field of bulls. The bulls ran up behind me, and when the lead one tried to stop he just carried on skidding forwards across the muddy field towards me. But luckily he stopped before he got me.

The main annoying thing about the walk was that the footpath ended up at a road, and then there wasn't any way to get back to the town except walking back along the side of the road, or going all the way back down the footpath I'd walked across. Also, the path wasn't very well sign posted when it got into Northamptonshire.

When I got back home I geo-coded and sorted the photos, then had dinner.

After dinner I played on Kirby Wii with Belly and Mauser, then we all went to see KK in animal crossing. After that I went to bed about 9pm as I felt really sleepy and had a headache.

Friday, 2 December 2011

Various stuff

This morning I helped someone with their wireless printer / internet not working properly. I spent quite a while trying to figure out why their laptop couldn't connect to the printer. Then when I tried to go on the internet to google for info, I found that actually the problem was that the laptop wasn't connected to the router. Doh! The problem actually seemed to be with the BT wireless connection software they had installed.

The BT software said that it was connected OK, but the internet and printer wouldn't work. If you went into Windows Wireless settings and selected something like 'Use Windows to configure my wirless settings', then the wireless would work OK. But upon restarting the computer, the BT software would take over again, and it would stop working. So I went into msconfig and disabled a couple of startup programs that looked like they might be the BT software. After restarting, it worked okay, and could now connect to the printer. Yay!

I spent most of the afternoon writing an article for my photo tips website.

In the evening I played on Kirby Wii with Mauser and Bo for a bit, and then photoshopped some Boglins of them:

Thursday, 1 December 2011

Site Analysing

Someone had replied to my question on the jquery forums about debugging why an AJAX request failed, and they asked me to post exactly what is in the responseText. I did try printing out responseText as part of my debugging yesterday, but as it contained HTML, it was being converted to HTML rather than printed as plain text. I remembered this morning about textNodes, and decided to try printing the responseText as a textNode. I used jquery's text() method, and this worked fine.

The only difference between the responseText printed by jquery and the content body of the server's response was that text() collapsed multiple whitespace to a single space. I posted the responseText to the thread as had been requested, though haven't received any reply yet. I am actually quite surprised I got a reply at all, I don't seem to have much luck getting replies (particularly helpful replies) on forums.

I would say sitepoint is probably the best forum, out of the 24 threads I've started there, I got helpful replies on 12 of them. Usually I get replies from people trying to be helpful as well, I only have a few threads there with no replies. For this jquery issue I get the feeling I'm going to have to spend many hours whittling my code down and constant testing until it either starts working or I have a test case suitable for filing a bug report.

I also processed a pano today, and ran the ISS Site Analyser a couple of times on my site. It did find lots of stuff wrong with my site, so still lots to fix.