Wednesday, May 9, 2012

Install PDO_OCI in Centos

First install oracle instant client
Download Oracle Instant Client (basic and devel) from here:
    http://www.oracle.com/technetwork/topics/linuxsoft-082809.html

Install
    rpm -ivh oracle-instantclient11.2-basic-11.2.0.1.0-1.i386.rpm
    rpm -ivh oracle-instantclient11.2-devel-11.2.0.1.0-1.i386.rpm

Optional - Add the Oracle instant client to dynamic linker
    echo /usr/include/oracle/11.2/client/lib/ > /etc/ld.so.conf.d/oracle_client.conf
    ldconfig -v
    If not working then type below command (Both do the same thing)
    echo /usr/lib/oracle/11.2/client/lib/ > /etc/ld.so.conf.d/oracle_client.conf

Optional - Oracle Profile
    Create a new file in /etc/profile.d named oracle.sh and include the following:
        export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client/lib/
        export     ORACLE_HOME=/usr/lib/oracle/11.2/client/lib/
      
Save the file with :wq Enter
    Run:
        source /etc/profile.d/oracle.sh

Download pdo_oci
Download pdo_oci from there:
        http://pecl.php.net/package/PDO_OCI/1.0

Untar the package and prepare it for compiling (using directory /opt/oracle/src/)
   tar -xzvf PDO_OCI-.tgz
   cd PDO_OCI-
   phpize
Example
   tar –xzvf PDO_OCI-1.0.tgz
   cd PDO_OCI-1.0
   phpize

Patch
If you work with Oracle Instant Client version 11.2, you need edit the config.m4 file and add the following after exploding the src look for similar sections:
Block 1:
   elif test -f $PDO_OCI_DIR/lib/libclntsh.$SHLIB_SUFFIX_NAME.11.2; then
   PDO_OCI_VERSION=11.2
Block 2
   11.2)
      PHP_ADD_LIBRARY(clntsh, 1, PDO_OCI_SHARED_LIBADD)
     ;;

Compiler
(IMP) Please run phpize command again in PDO_OCI folder else Patch won't work

   ./configure  --with-pdo-oci=instantclient,/usr,11.2
   make
   make install

If above command not working please run below command otherwise continue with next step
./configure  --with-pdo-oci=instantclient,/usr/lib/oracle/11.2/client/lib
make
make install

Include in files to php parsed
Create a new file in /etc/php.d named pdo_oci.ini and include the following

   extension=pdo_oci.so

Start apache
   service httpd start  or /etc/init.d/httpd restart

It's Done.........:)
Write to me bhagwat@outlook.in if you need more support on this

No comments:

Post a Comment