I recently had to build pdo_oci.so and I could not find a proper guide to do it. Hopefully this one will help someone.
create a file on document root called test.php
vi /srv/www/htdocs/test.php
<?php phpinfo(); ?>
Browse to http://yourserverip/test.php, on top is the version mine is 5.3.17
Download the correct source http://php.net/releases/ I used this link http://museum.php.net/php5/php-5.3.17.tar.gz
Now copy the downloaded source to ~/php-build
tar -zxvf php-5.3.17.tar.gz cd php-5.3.17
Oracle Server installed
./configure --with-apxs2=/usr/sbin/apxs2 --with-pdo-oci=shared --with-oci8=shared --with-config-file-path=/etc/php5/apache2/php.ini --with-config-file-scan-dir=/etc/php5/apache2 --with-ldap make cd ext/pdo_oci ;edit the config.m4 file vi config.m4
search for 11
and change
case $PDO_OCI_VERSION in
9.0|10.1|10.2|11.1|11.2)
PHP_ADD_LIBRARY(clntsh, 1, PDO_OCI_SHARED_LIBADD)
;;
to
case $PDO_OCI_VERSION in
9.0|10.1|10.2|11.1|11.2|12.1|12.2)
PHP_ADD_LIBRARY(clntsh, 1, PDO_OCI_SHARED_LIBADD)
;;
do a pwd make sure you are in ext/pdo_oci directory
phpize ./configure --enable-shared make
Instant Client
For the instant client you might get error like:
checking Oracle Instant Client library version compatibility… configure: error: Link from /usr/lib/oracle/libclntsh.so to /usr/lib/oracle/libclntsh.so.*
cd /usr/lib/oracle sudo ln libclntsh.so.12.1 libclntsh.so
Then configure like
./configure --with-apxs2=/usr/bin/apxs2 --with-pdo-oci=shared,instantclient,/usr/lib/oracle --with-oci8=shared,instantclient,/usr/lib/oracle
To Build the shared object
cd ext/oci8/ phpize ./configure --enable-shared -with-oci8=instantclient,/usr/lib/oracle make
OR PDO_OCI
cd ext/pdo_oci phpize ./configure --enable-shared -with-pdo-oci=instantclient,/usr/lib/oracle make
Add the following to the file :
; comment out next line to disable pdo_oci extension in php extension=pdo_oci.so
tail -f /var/log/apache2/error.log
if you get
Unable to load dynamic library ‘pdo_oci.so’ (tried: /usr/lib/php/[SOMENUMBER]/pdo_oci.so (libmql1.so: cannot open shared object file: No such file or directory)
Add Oracle libs to the LD_LIBRARY_PATH
cd /etc/ld.so.conf.d #Create file oracle and add /usr/lib/oracle sudo vi oracle
and if that does not work then
cd /etc/apache2/ sudo vi envvars #and add export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/oracle #to the end of the file
Restart the apache server or you can do
php -i | grep pdo
to see if its loaded.