Tuesday 9 June 2009

Trying to build mysqli extension for php

This morning I vacuumed my room, and found some weird green and yellow splats on the floor by my bed. Then I found some more near the bottom of my bed sheet and a dead caterpillar.

Obviously it had somehow got into my bed, and I'd squashed it with my foot, then when I got up in the morning the juice on my foot had gone on the carpet.

It looked like the caterpillar from the Rose I found in the garden the other day. I had put the caterpillar, the Rose flower it was on, and a piece of iceberg lettuce in Ben's insect tank last night. It couldn't have escaped from the tank (unless it could climb up walls and squidge itself really thin to fit through the holes), and even it had, I wouldn't have thought it would go all the way across my room and climb up into my bed.

So the only thing I can think of is that Moccle took it out of the tank last night while I was asleep and put it in my bed. I wouldn't have thought he'd do that though since he's quite squeamish about insects. I did check in the tank to make sure it wasn't a different caterpillar, but couldn't find the caterpillar in the tank at all. Very weird, since it was definitely in there last night.

After vacuuming my room I had to change my bed sheet and also cleaned up the squashed caterpillar juice and some tea stains from the carpet. I cleaned the bird table tray bit as well.

I carried on trying to install PHP 2.9 on CentOS 5.3, first problem was I got the error
xml2-config not found. Please check your libxml2 installation.
So I had to yum install libxml2-devel.

Then I found that MySQL wasn't installed (or at least wasn't installed where it should have been). I was sure I installed it yesterday, but I guess I must not have.

After installing MySQL, I tried compiling PHP. I looked in the different directories where I'd compiled PHP to, and couldn't see any extension modules. I also tried ls -R | grep -i mysql from the php installation directory, but that came up blank. On the PHP Manual page for installing PHP for Apache 2, I read some comments that said to install mysql-devel, so I installed that.

Also on the PHP Manual page, they have --with-apxs2=/usr/local/apache2/bin/apxs as a configure option. I tried to find apxs, but couldn't and refering to httpd instead didn't work. So I did some more googling, and found I needed to yum install httpd-devel. After doing that, I found I had apxs in /usr/sbin/.

I tried compiling again, but still the same thing - no extension files for mysql or mysqli were created.

I did some more googling and found some messages from people saying that mysql/mysqli was working okay even though they didn't have the mysql.so/mysqli.so files. So maybe PHP when compiled with --with-mysqli doesn't generate the extension files and just includes it inside its own internal code or something?

Anyway, after that I read some other stuff on Google, and was looking at the php5.spec file inside the PHP source folder. I couldn't see how to do what was suggested about adding/removing lines from the .spec file, but while I was in the PHP source folder, I did see a file called 'README.SELF-CONTAINED-EXTENSIONS'.

So I read that, and it said that you can compile indivdual extensions, such as the mysql extension by themselves, so long as you phpize them first.

So I downloaded the php source on the web server, phpized and make installed the mysqli extension on there. It worked, and created a mysqli.so file in the extensions directory php was using. I added "extension=mysqli.so" so the php.ini file that phpinfo() said was being loaded.

However, after restarting the phpstack, I was still getting the same version of mysqli extension loaded as I was before. I checked the error logs and found
PHP Warning: Module 'mysqli' already loaded in Unknown on line 0


I checked phpinfo(), and it didn't say it was loading any other php.ini files, and the one it was loading certainly didn't have about loading mysqli twice in it. After lots of googling I did find -name php.ini from my webapps directory, but that only brought up 2 files - the one in use and another one that wasn't in use and didn't specify mysqli in it anyway.

Eventually I gave up and sent a message to WebFaction to see what I need to do to get it working.

After dinner I watched 3 episodes of The Office (US) with Moccle, then watched Springwatch with Ben, Clare and Brian. Then after that I checked my email and dpreview.

The weather today was overcast all day, but not very windy.

Food
Breakfast: Orange marmalade toast sandwich; cup o' tea.
Lunch: Mature cheddar cheese with sweet & crunchy salad sandwich; Clementine; banana; Rocky; cup o' tea.
Dinner: Chicken pastry thing; potatoes; baked beans; brown sauce. Pudding was ginger sponge with golden syrup and custard. Coffee; Oreo.
Supper: Hot chocolate; fake jammy dodger; choc chip cookie.

No comments: