1 0 Tag Archives: patch

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)

1. 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.rpm2.

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.

1. Download latest oci8-package from http://pecl.php.net/package/oci8
2. Extract package somewhere
3. Go to php-4.4.x-source directory
4. rm -rf ext/oci8
5. cp extracted oci8-1.2.x directory to/as ext/oci8
6. make distclean
7. ./buildconf –force
8. ./configure –with-oci8=$ORACLE_HOME (
other options you need)
9.
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 (thats a capital i ) save the Makefile, then finish off compiling and installing php.

10. make
11. edit Makefile:
replace:
PEAR_INSTALL_FLAGS = -n -dshort_open_tag=0 -dsafe_mode=0
with:
PEAR_INSTALL_FLAGS = -cpear-install.ini -dshort_open_tag=0 -dsafe_mode=0
12. make 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.htmlThe 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.

1. After setting up the PHP5 source and Oracle Instant Client’s directories and the variables, run the buildconf script:

./buildconf –force2. ./configure –with-oci8=$ORACLE_HOME (other options you need)
3.
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

(thats a capital i ) save the Makefile, then finish off compiling and installing php.

4. make
5. make test
6. make 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.patch
cd php-5.0.3
rm -rf autom4te.cache config.cache
./buildconf –force

I hope this will help many people.

Read full story »