Installazione driver oracle PDO_OCI per PHP


Installazione driver oracle PDO_OCI per PHP

Dependencies

Oracle

Installing Oracle is easy. You can follow this tutorial in installing Oracle 11g Express.

Development packages
 
$ sudo yum install php-pear php-devel zlib zlib-devel bc libaio glibc
$ sudo yum groupinstall "Development Tools"


InstantClient

Download Oracle InstantClient RPM files here. Put these files in your server. Download the basic and devel packages.
  • Basic: oracle-instantclient-basic-10.2.0.3.i386.rpm
     
  • Devel: oracle-instantclient-devel-10.2.0.3.i386.rpm

Install the downloaded rpm files:
 
$ sudo rpm -ivh oracle-instantclient-basic-10.2.0.3.i386.rpm
$ sudo rpm -ivh oracle-instantclient-devel-10.2.0.3.i386.rpm

$ sudo ln -s /usr/include/oracle/10.2/client64 /usr/include/oracle/10.2/client
$ sudo ln -s /usr/lib/oracle/10.2/client64 /usr/lib/oracle/10.2/client


Create a file inside /etc/profile.d named oracle.sh and put this as the content:
 
export LD_LIBRARY_PATH=/usr/lib/oracle/10.2.0.3/lib


And run it so we’ll have LD_LIBRARY_PATH as an environment variable.

source /etc/profile.d/oracle.sh
 

PDO_OCI

Download the PDO_OCI source using pecl.
 
$ pecl download PDO_OCI
$ tar -xvf PDO_OCI-1.0.tgz
$ cd PDO_OCI-1.0


Inside the PDO_OCI-1.0 folder, edit the file named config.m4.

Find a pattern like this near line 10 and add these 2 lines:
 
elif test -f $PDO_OCI_DIR/lib/libclntsh.$SHLIB_SUFFIX_NAME.10.2; then
  PDO_OCI_VERSION=10.2

Find a pattern like this near line 101 and add these lines:
 
10.2)
  PHP_ADD_LIBRARY(clntsh, 1, PDO_OCI_SHARED_LIBADD)
  ;;


Build and install the extension.

 
$ phpize
$ ./configure --with-pdo-oci=instantclient,/usr,10.2.0.3

$ make
$ sudo make install


To enable the extension, add a file named pdo_oci.ini under /etc/php.d and put this as the content:
 
extension=pdo_oci.so


Validate that it was successfully installed.
 
$ php -i | grep oci


You should see something like this in the output:
 
/etc/php.d/pdo_oci.ini,
PDO drivers => oci, odbc, sqlite