php5 most definitely with mysql
September 28th, 2006
WTF?!
I've been out of the php world for a while it seems. We've recently had to move some old project from a shared host to our server. I prepared myself for upgrading old php4 stuff to php5. Not fun, but not terrible. Time comes to deploy... and mysql is not installed in the apache php module...!?
So I check yum
$ yum list | grep php-mysql php-mysql.i386 5.0.4-10.5 installed
WTF!?
So I knock up a phpinfo page and check it, and sure enough it's been compiled --without-mysql. WTF!? Turn's out that since php5 automatic support for the mysql extension is turned off. I'm so over php these days that I couldn't even be bothered to rant.
Because I didn't want to waste any precious rails time on this stuff, I just went straight for the jugular and decided to recompile php --with-mysql--duh
Thanks to an article at fedoranews.org, it was a not so painful. In fact following the instructions over at php.net will get you there in the end.
But, systems differ, so if you're running FC4, you should be able to get things up and running with the following commands and config.
Plan and assumptions
I assume you've got http-2.0.54 (the current FC4 release) and mysql already installed (and the php-mysql.i386 package which is causing the problem). The plan is to configure php just like the one you get with yum, but with mysql, and without some other problematic dependencies which are not easy to get with yum.
Install required dependencies
yum install curl-devel.i386 \
bzip2-devel.i386 \
libxml2-devel.i386 \
flex.i386 \
gmp-devel.i386 \
httpd-devel-2.0.54 \
libc-client-devel
Get php, configure and make it
wget http://us2.php.net/get/php-5.1.6.tar.gz/from/www.php.net/mirror tar -zxvf php-5.1.6.tar.gz cd php-5.1.6
./configure \ '--build=i386-redhat-linux' '--host=i386-redhat-linux' \ '--target=i386-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' \ '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' \ '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' \ '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' \ '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' \ '--infodir=/usr/share/info' '--cache-file=../config.cache' \ '--with-libdir=lib' '--with-config-file-path=/etc' \ '--with-config-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' \ '--disable-rpath' '--with-bz2' '--with-curl' '--with-exec-dir=/usr/bin' \ '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' \ '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' \ '--with-jpeg-dir=/usr' '--with-openssl' '--with-png' '--without-pspell' \ '--with-expat-dir=/usr' '--with-pcre-regex=/usr' '--with-zlib' \ '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' \ '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' \ '--enable-track-vars' '--enable-trans-sid' '--enable-yp' '--enable-wddx' \ '--with-pear=/usr/share/pear' '--with-kerberos' '--enable-ucd-snmp-hack' \ '--without-unixODBC' '--enable-memory-limit' '--enable-shmop' \ '--enable-calendar' '--enable-dbx' '--enable-dio' \ '--with-mime-magic=/etc/httpd/conf/magic' '--without-sqlite' \ '--with-libxml-dir=/usr' '--with-xml' '--with-apxs2=/usr/sbin/apxs' \ '--with-mysql' '--without-gd' '--without-odbc' '--disable-dom' \ '--disable-dba' '--with-imap-ssl'
make(Ignore lots of pointer warnings)
Install php and configure Apache
/sbin/service httpd stop make install
Now we need to make apache look for the new compiled module. On my dist the
php config is in /etc/httpd/conf.d/php.conf, it may be in
/etc/httpd/conf/httpd.conf on yours.
Open the conf file, locate the following line:LoadModule php5_module modules/libphp5.so
and replace it with:
LoadModule php5_module /usr/lib/httpd/modules/libphp5.so
Let go of your attachments and desires
(like the idea of your server working) Now you're in the best state of mind to issue the final command.
/sbin/service httpd start
Write a phpinfo page and check that everything works.
May 23rd, 2007 at 02:04 PM Thanks for post
October 16th, 2007 at 02:05 PM Make sure that you are using the same source version as the one included with the distribution - otherwise: great sadness & frustration. my story: i had apache/php but no php-mysql. so i try to turn on the php-mysql that comes with centos5 - no luck, because the mysql on the server was installed separately, so there were version conflicts and other complaints, etc, etc. so i have to install php from source --with-mysql so i get the latest .tar of php (something like php-5.2.4.tar.gz), unpack it, ./configure it --with-mysql and everything else like above, then make, then httpd stop, then make install, and then httpd start and then - sorry - can not load libphp5.so - sapi_global failure something @#$@#$% try it again, plus 10 or 12 other things, finally get the solution: go back and check what php version came with the distribution - sure enough - just like above php-5.1.6 - so i go get that (at museum.php.net/php5/) download, unpack, ./configure, make, make install, and httpd start with a happy green [OK] and no apologies for taking 8 hours out of my work week.