Installing PDO_OCI for PHP

It has taken quite a few hours to piece together how to install PDO_OCI for PHP in OpenSUSE. I have compiled a small how-to if anyone else has a need for this. Enjoy


Download these files from oracle.com and install using using rpm
Oracle Software Downloads

oracle-instantclient-basic-10.2.0.3-1.i386.rpm
oracle-instantclient-devel-10.2.0.3-1.i386.rpm

Run these commands in order

cd /tmp

wget http://pecl.php.net/get/PDO_OCI

tar zxvf PDO_OCI

cd PDO_OCI-1.0/

phpize

# This will tell ./configure where Oracle is at
export ORACLE_HOME=/usr/lib/oracle/10.2.0.3/client

**# Create symbolic link to php5 include directory

OpenSUSE uses php5, configure wants php**

ln -nsf /usr/include/php5 /usr/include/php

./configure --with-php-config=php-config –with-pdo-oci=instantclient,/usr,10.2.0.3

make
make install

# Create symbolic link to Oracle’s libnnz10.so
ln -s /usr/lib/oracle/10.2.0.3/client/lib/libnnz10.so /usr/lib/libnnz10.so

# Create single line conf.d file to load extension in php
vi /etc/php5/conf.d/pdo_oci.ini
extension=pdo_oci.so

Run php -m and make sure PDO_OCI is listed.

You should be set!

Since this original post, I have done this same setup on a x64 bit system. There are a few tweaks…

  1. Download and install the x86_64 versions of the Oracle instantclient:

    • oracle-instantclient-basic-10.2.0.3-1.x86_64.rpm
    • oracle-instantclient-devel-10.2.0.3-1.x86_64.rpm
  2. ./configure is going to want to use …/10.2.0.3/client. The 64-bit version of the instantclient uses …/10.2.0.3/client64. Before running ./configure, run these two commands:

    • ln -nsf /usr/lib/oracle/10.2.0.3/client64 /usr/lib/oracle/10.2.0.3/client
    • ln -nsf /usr/include/oracle/10.2.0.3/client64 /usr/include/oracle/10.2.0.3/client
  3. When you created the symlink to …/client64/lib/libnnz10.so, put the symlink in lib64:

    • ln -s /usr/lib/oracle/10.2.0.3/client64/lib/libnnz10.so /usr/lib64/libnnz10.so

NOTE: these instructions can be used in both OpenSUSE and SUSE Linux Enterprise

Hello, Guys!
I followed your procedure and installed pdo_oci on a 32 bit opensuse 12.1. php -v, php -m all ok. I can see pdo_oci. But when I created a index.php which is phpinfo(), I cannot find oci enabled. All mysql, sqlite and pgsql, odbc are there. Just missing pdo_oci. I do have a pdo_oci.ini in /etc/php5/conf.d/, I do not know why.

  1. Download and install the x86_64 versions of the Oracle instantclient:
    oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm
    oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm

  2. ./configure is going to want to use …/11.2/client. The 64-bit version of the instantclient uses …/11.2/client64. Before running ./configure, run these two commands:
    ln -nsf /usr/lib/oracle/11.2/client64 /usr/lib/oracle/11.2/client
    ln -nsf /usr/include/oracle/11.2/client64 /usr/include/oracle/11.2/client64

  3. When you created the symlink to …/client64/lib/libnnz11.so, put the symlink in lib64:
    ln -s /usr/lib/oracle/11.2/client64/lib/libnnz11.so /usr/lib64/libnnz11.so

Run these commands in order

cd /tmp

wget http://pecl.php.net/get/PDO_OCI

tar zxvf PDO_OCI

cd PDO_OCI-1.0/

phpize

This will tell ./configure where Oracle is at

export ORACLE_HOME=/usr/lib/oracle/11.2/client

Create symbolic link to php5 include directory

OpenSUSE uses php5, configure wants php

ln -nsf /usr/include/php5 /usr/include/php

./configure --with-php-config=php-config --with-pdo-oci=instantclient,/usr,11.2

This is my problem

./configure --with-php-config=php-config --with-pdo-oci=instantclient,/usr,11.2
configure: loading site script /usr/share/site/x86_64-unknown-linux-gnu
checking for grep that handles long lines and -e… /usr/bin/grep
checking for egrep… /usr/bin/grep -E
checking for a sed that does not truncate output… /usr/bin/sed
checking for gcc… gcc
checking whether the C compiler works… yes
checking for C compiler default output file name… a.out
checking for suffix of executables…
checking whether we are cross compiling… no
checking for suffix of object files… o
checking whether we are using the GNU C compiler… yes
checking whether gcc accepts -g… yes
checking for gcc option to accept ISO C89… none needed
checking for gcc option to accept ISO C99… -std=gnu99
checking for gcc -std=gnu99 option to accept ISO Standard C… (cached) -std=gnu99
checking how to run the C preprocessor… gcc -std=gnu99 -E
checking for ANSI C header files… yes
checking for sys/types.h… yes
checking for sys/stat.h… yes
checking for stdlib.h… yes
checking for string.h… yes
checking for memory.h… yes
checking for strings.h… yes
checking for inttypes.h… yes
checking for stdint.h… yes
checking for unistd.h… yes
checking minix/config.h usability… no
checking minix/config.h presence… no
checking for minix/config.h… no
checking whether it is safe to define EXTENSIONS… yes
checking for icc… no
checking for suncc… no
checking whether gcc -std=gnu99 and cc understand -c and -o together… yes
checking for system library directory… lib
checking if compiler supports -R… no
checking if compiler supports -Wl,-rpath,… yes
checking build system type… x86_64-unknown-linux-gnu
checking host system type… x86_64-unknown-linux-gnu
checking target system type… x86_64-unknown-linux-gnu
checking for PHP prefix… /usr
checking for PHP includes… -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib
checking for PHP extension directory… /usr/lib64/php5/extensions
checking for PHP installed headers prefix… /usr/include/php5
checking if debug is enabled… no
checking if zts is enabled… no
checking for re2c… re2c
checking for re2c version… 0.13.5 (ok)
checking for gawk… gawk
checking Oracle OCI support for PDO… yes, shared
checking Oracle Install-Dir… instantclient,/usr,11.2 :instantclient,/usr,11.2:
checking if that is sane… yes
checking for oci.h… configure: error: I’m too dumb to figure out where the include dir is in your instant client install

download the patch → php.net/viewvc/php/php-src/branches/PHP_5_3/ext/pdo_oci/config.m4?view=markup&pathrev=294487

Is the same :confused:

How do I fix the problem?