PHP 5.4 compilation with PDO-OCI driver using Oracle Instant client 10.2.0.4

Kishore picture Kishore · Dec 3, 2013 · Viewed 11.7k times · Source

I have downloaded Instant client 10.2.0.4 basic and sdk zip files from Instant Client downloads for Mac OS X (Intel x86),

I extracted into a folder as shown below

-rw-r--r--@ 1 MNV_Kishore  1000     278 Apr  1  2009 BASIC_README
-r--r--r--@ 1 MNV_Kishore  1000 1609607 Feb  2  2008 classes12.jar
-rwxr-xr-x@ 1 MNV_Kishore  1000     34168 Apr  1  2009 genezi
lrwxr-xr-x  1 MNV_Kishore  wheel        20 Dec  2 18:10 libclntsh.dylib -> libclntsh.dylib.10.1

-rwxr-xr-x@ 1 MNV_Kishore  1000   25582048 Mar 31  2009 libclntsh.dylib.10.1
-rwxr-xr-x@ 1 MNV_Kishore  1000 2062528 Mar  3  2009 libnnz10.dylib
lrwxr-xr-x  1 MNV_Kishore  wheel        18 Dec  2 18:10 libocci.dylib -> libocci.dylib.10.1
-rwxr-xr-x@ 1 MNV_Kishore  1000 1277896 Mar  3  2009 libocci.dylib.10.1

-rwxr-xr-x@ 1 MNV_Kishore  1000   72626768 Apr  1  2009 libociei.dylib
-rwxr-xr-x@ 1 MNV_Kishore  1000     118672 Mar 25  2009 libocijdbc10.dylib
-rwxr-xr-x@ 1 MNV_Kishore  1000     118672 Mar 25  2009 libocijdbc10.jnilib
-r--r--r--@ 1 MNV_Kishore  1000 1555682 Feb  2  2008 ojdbc14.jar
drwxr-xr-x@ 7 MNV_Kishore  wheel    238 Apr  1  2009 sdk

All header files .h are present in include dir under sdk

When I tried to configure with command as...

./configure --with-pdo-oci=instantclient,/usr/local/instantclient_10_2,10.2.0.4

... the below error is encountered

checking for oci.h... configure: error: I'm too dumb to figure out where the include dir is in your instant client install

Could any one please help me with this error?

Answer

Eric picture Eric · Dec 3, 2013

We recently had to install this on a CentOS box, so the paths might be a little different. Also, we used a pre-compiled PHP instance, and added the OCI8 functions as a separate module. Before using CentoOS, we installed to our Mac workstations using these instructions (they are a bit dated, so I don't know if this will still work with current versions of OS X and PHP): http://articles.serenity.de/compiling_php_with_oracle/

For our CentOS install, we had to do the following:

  • Install/compile PHP 5.4 without instant client support.

  • Get the instantClient basic and SDK packages and install them (looks like you already have both).

  • When the OCI configure scirpt claims that it is too dumb to find the headers, it's not being sarcastic, so you have tot set up a rat's nest of symlinks. On CentOS, the basic client is installed in /usr/lib/oracle/10.2.0.3/client64, and the SDK files are in /usr/include/oracle/10.2.0.3/client64/.

cd /usr/lib/oracle/10.2.0.3/client64
cp /usr/include/oracle/10.2.0.3/client64/* .
ln -s lib/libnnz10.so libnnz.so
ln -s lib/libclntsh.so.10.1 libclntsh.so
ln -s lib/libnnz10.so libnnz10.so
ln -s lib/libclntsh.so.10.1 libclntsh.so.10.1
  • Now you can install OCI8 from pecl. Note that at this point PDO_OCI will not work. This is ONLY for the OCI8 driver:

pecl install oci8

  • For PDO_OCI support you will also need to add some more symlinks:
cd /usr/lib/oracle/10.2.0.3/client64
mkdir sdk
cd sdk && ln -s /usr/include/oracle/10.2.0.3/client64 include
ln -s /usr/lib/oracle/10.2.0.3/client64/sdk/include/ /usr/lib/oracle/10.2.0.3/client/include
ln -s /usr/lib/oracle/10.2.0.3/client64/ /usr/lib/oracle/10.2.0.3/client
ln -s /usr/include/oracle/10.2.0.3/client64/ /usr/include/oracle/10.2.0.3/client
  • PDO OCI has been not been maintained for several years, so it won't install directly from pecl. Instead, you will have to download it and make some changes. The sed command updates function_entry to zend_function_entry so that it will compile properly:
pecl download pdo_oci
tar -xvf PDO_OCI-1.0.tgz
cd PDO_OCI-1.0
sed -i -e 's/function_entry pdo_oci_functions/zend_function_entry pdo_oci_functions/' pdo_oci.c
mkdir include
ln -s /usr/include/php include/php
phpize
cp /usr/include/oracle/10.2.0.3/client64/* ./include
./configure --with-pdo-oci=instantclient,/usr,10.2.0.3
make && make install

At this point PDO_OCI should work with your PHP install. If you are still having trouble, you can look in the configure and make scirpts to see which dircotories and symlinks are expected for your system. Brad was speaking literally when he said that this took days to figure out. Hopefully it will help you get it working much faster.