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
make
cd ext/pdo_oci
;edit the config.m4 file
vi config.m4
[/sourcecode]
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
[sourcecode language=”shell”] phpize./configure –enable-shared
make
[/sourcecode]
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.*
sudo ln libclntsh.so.12.1 libclntsh.so
[/sourcecode] Then configure like
[sourcecode language=”shell”] ./configure –with-apxs2=/usr/bin/apxs2 –with-pdo-oci=shared,instantclient,/usr/lib/oracle –with-oci8=shared,instantclient,/usr/lib/oracle
[/sourcecode]
To Build the shared object
[sourcecode language=”shell”] cd ext/oci8/phpize
./configure –enable-shared -with-oci8=instantclient,/usr/lib/oracle
make
[/sourcecode] OR PDO_OCI
[sourcecode language=”shell”] cd ext/pdo_oci
phpize
./configure –enable-shared -with-pdo-oci=instantclient,/usr/lib/oracle
make
now there should be a folder modules
cd modules
ls -l ;should show a pdo_oci.so
sudo cp pdo_oci.so /usr/lib64/php5/extensions
cd /etc/php5/conf.d/
sudo vi pdo_oci.ini
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.