Compile PHP 4 & 5 on Linux with OCI8 Support using Instant Client
I had a headache trying to compile PHP4 and PHP5 with OCI8 support and thanks to some PHP manual comments; I was able to build PHP4 & 5 successfully on Linux. The reason I post this is because this can prove to be a nueisance to people, especially PHP4. So here goes:
For both PHP4 and PHP5 compilations, you must perform the following:
- Download PHP source
- Download Oracle Instant Client (Basic + SDK + SQLPlus (optional) )
- Download libxml (optional)
- Install the Instant Client RPMs using:
rpm -ivh oracle-instantclient-basic-10.2.0.3-1.i386.rpm oracle-instantclient-devel-10.2.0.3-1.i386.rpm oracle-instantclient-sqlplus-10.2.0.3-1.i386.rpm
- Set ORACLE_HOME as
export ORACLE_HOME=/usr/lib/oracle/10.1.0.3/client;export LD_LIBRARY_PATH=/usr/lib/oracle/10.1.0.3/client/lib;
Now to compile PHP4 with OCI8
PHP4 has many problems compiling with OCI8 and the following is a solution.
- Download latest oci8-package from http://pecl.php.net/package/oci8
- Extract package somewhere
- Go to php-4.4.x-source directory
cp extracted oci8-1.2.x directory to/as ext/oci8make distclean./buildconf --force./configure --with-oci8=$ORACLE_HOME
- The compiler needs to find the includes oci.h + others so, from the default client install dirs, edit the php Makefile after it was configured. Open it up and look for “EXTRA_INCLUDES” and add to end of line
-I/usr/include/oracle/10.1.0.3/client (save the Makefile, then finish off compiling and installing php)make
edit Makefile and replace:
PEAR_INSTALL_FLAGS = -n -dshort_open_tag=0 -dsafe_mode=0
PEAR_INSTALL_FLAGS = -cpear-install.ini -dshort_open_tag=0 -dsafe_mode=0make install
You should be happy and dandy running PHP4. Also, a note to people who are compiling PHP4. Oracle released patches for the instant client to compile with PHP:
http://www.oracle.com/technology/pub/notes/technote_php_instant.html The patches provided from Oracle are for PHP Versions 4.3.9 or 4.3.10. For PHP5, look in the PHP5 section.
To compile PHP5 with OCI8
Compiling with PHP5 isn’t that different but you don’t need to do all that fuss that was required in PHP4. Also, there is no need for any patches in versions after PHP 5.2.x.
- After setting up the PHP5 source and Oracle Instant Client’s directories and the variables, run the buildconf script:
./buildconf --force./configure --with-oci8=$ORACLE_HOME
The compiler needs to find the includes oci.h + others so, from the default client install dirs, edit the php Makefile after it was configured. Open it up and look for “EXTRA_INCLUDES” and add to end of line
-I /usr/include/oracle/10.1.0.3/clientmakemake testmake install
And you’re done.
Please note that I have taken much of this material from the official PHP forums on OCI. If you need help, please visit the following page: http://www.php.net/manual/en/ref.oci8.php
Also, the php 5.0.3 patch I was talking above can be found here coutesy of
You can apply the patch as follows :
patch -u php-5.0.3/ext/oci8/config.m4 php5_ociclient.patchcd php-5.0.3rm -rf autom4te.cache config.cache./buildconf --force
I hope this will help many people.
© 2016 Most of the work on this site is mine, ask before using. Thanks. –