Bluhalo IT


Compiling PHP with Oracle support on CentOS 5.2

Posted in Apache,linux by Simon Green on April 30, 2009

Getting PHP and oracle to play nice is a massive pain, so this post is more a log for myself next time I have to do it more than anything else!

The procedure requires you to compile PHP from source, so if thats not your thing or your easily scared don’t bother continuing!

Firstly an enormous yum install command to get everything we need in one go:

# yum install openssh-server httpd httpd-devel apxs libx openssl-devel curl-devel libpng-devel\
 oci8-devel libxml libxml2 libxml2-devel libjpeg libXpm libXpm-devel libpng libxslt libxslt-devel\
 freetype freetype-devel

Go and grab the instant client from the oracle website and install it with RPM:

# rpm -i oracle-instantclient11.1-basic-11.1.0.7.0-1.i386.rpm
# rpm -i oracle-instantclient11.1-devel-11.1.0.7.0-1.i386.rpm

And then get the PHP source (substitute for whatever the latest version is at your compile time obviously):

# wget http://uk.php.net/get/php-5.2.8.tar.gz/from/this/mirror
# tar -xzf php-5.2.8.tar.gz
# cd php-5.2.8

And finally configure it all together:

# ./configure  --with-apxs2=/usr/sbin/apxs --with-zlib --without-gdbm --enable-force-cgi-redirect\
 --enable-ftp --enable-xml --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 --mandir=/usr/share/man --infodir=/usr/share/info\
 --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-pear --enable-pdo\
 --with-oci8=instantclient,/usr/lib/oracle/11.1/client/lib --with-pdo-oci=instantclient,/usr,11.1\
 --with-xsl --with-curl --with-openssl --enable-soap --enable-sockets --enable-sigchild --enable-xdebug\
 --with-jpeg-dir --with-xpm-dir --with-png-dir --with-freetype-dir --with-ttf --enable-gd-native-ttf --with-gd

And with a bit of luck you should be up and running. Obviously now you have to do battle with Oracle itself which is a minefield of confusion!

Leave a comment