Linux install oracle instant client + PHP PDO_OCI library

Download appropriate oracle instant client
(base and sdk packages important!)

instantclient-basic-linux.x64-11.2.0.4.0.zip
instantclient-sdk-linux.x64-11.2.0.4.0.zip

 Extract those files in a directory

/opt/instantclient_11_2

Set oracle home variable

export ORACLE_HOME=/opt/instantclient_11_2/

Create symlinks for libraries

ln -s /opt/instantclient_11_2/libclntsh.so.11.1 /opt/instantclient_11_2/libclntsh.so
ln -s /opt/instantclient_11_2/libocci.so.11.1 /opt/instantclient_11_2/libocci.so
ln -s /opt/instantclient_11_2/ /opt/instantclient_11_2/lib

Install PDO_OCI
If you already have php installed, you can compile only the PDO_OCI from PHP source. (Do not install with pecl because it’s deprecated)

  • Download the PHP source with same version that you have installed
  • Extract
  • Change to directory php-YOUR-VERSION/ext/pdo_oci

Run commands to compile PDO_OCI

phpize
./configure --with-pdo-oci=instantclient,/opt/instantclient_11_2,11.2
make && make install
echo "extension=pdo_oci.so" > /etc/php.d/pdo_oci.ini

Restart web server
service httpd restart