php-mysql

I checked my blog, and found out that WordPress had lost PHP.

Turns out as part of the Mysql upgrade to version 5 I had to uninstall php-mysql.
No binary or package of php-mysql for Mysql version 5 is available so I had to
compile it myself. It took awhile, here’s how it went:

The php module of Apache (httpd) incorporates mysql connection support. It is
built as part of the php build process. So I download php-5.0.4
(PHP).

Building the php webserver module requires the Apache source. I *really*
don’t want to totally build and replace my webserver, there are too many ways
to screw it up. So I’ll just build it, and use the build for making the php
module, but not replace my working web server with the new build.
Find out what version of Apache is installed:
&gr;rpm -qa | grep http
httpd-devel-2.0.51-2.7
httpd-2.0.51-2.7
system-config-httpd-1.2.0-3
httpd-manual-2.0.51-2.7

So find and download the httpd-2.0.51 source from the old version site,
old Apache
untar it, and build it:

./configure --enable-so --enable-cache --enable-cgi
--enable-rewrite=shared --enable-vhost-alias --enable-module=headers
--enable-module=perl --enable-module=log_agent --enable-module=log_referer
--enable-module=include
make
make install

Since I won’t use this build, the exact options aren’t critical. This installs it in the default location, /usr/local/apache2. My old version is still the active one though.

Now go to PHP, untar and build it.

./configure --enable-force-cgi-redirect --with-apxs2 --with-mysql=/usr
make
make install

I had to play around with the configure parameters and still got build errors:
----------------
/usr/bin/ld: /usr/lib64/mysql/libmysqlclient.a(libmysql.o): relocation
R_X86_64_32 can not be used when making a shared object; recompile with -fPIC
/usr/lib64/mysql/libmysqlclient.a(libmysql.o): could not read symbols: Bad
value
----------------

Looking around the web, it looks like php can’t find the shared mysql library.
I look at mysql:

ls -l /usr/lib64/*mysql*

and see a shared library in /usr/lib64 and a static one in /usr/lib64/mysql.
PHP is trying to use the /usr/lib64/mysql one instead of the /usr/lib64 one.
To fix this, I edit the Makefile, replace occurances of /usr/lib64/mysql with
/usr/lib64. Then ‘make clean’, ‘make’. Now it compiles fine.
Do ‘make install’.
It puts the Apache module in /usr/local/apache2/modules. Copy it to my module
dir:

cp /usr/local/apache2/modules/libphp5.so /etc/httpd/modules

Check that /etc/httpd/conf.d/php.conf points to it:
LoadModule php5_module modules/libphp5.so

restart the web server:

/etc/rc.d/init.d/httpd restart

and WordPress is back online!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>