Installing OCI8 on the CentOS

    1. Download the RPM instant client package from oracle website. Since it is Linux environment, use the this oracle linkInstall the RPMs as the root user
      rpm –ivh  oracle-instantclient12.1-basic-
      rpm –ivh  oracle-instantclient12.1-devel-
      rpm –ivh oracle-instantclient12.1-sqlplus-
    2. Install some prerequisite

yum install php-pear
yum install php-devel

  1. Set environment variables ORACLE_HOME and LD_LIBRARY_PATH# ORACLE_HOME=/usr/lib/oracle/12.1/client64; export ORACLE_HOME
    # LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATHYou should also add the above two lines in ~/.bash_profile file. Edit the file by vi editor and add the lines above PATH=$PATH:$HOME/bin#vim  ~/.bash_profile

    # .bash_profile
    # Get the aliases and functions
    if [ -f ~/.bashrc ]; then
    . ~/.bashrc
    fi# User specific environment and startup programsORACLE_HOME=/usr/lib/oracle/12.1/client64; export ORACLE_HOME
    LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
    PATH=$PATH:$HOME/binexport PATH


  2. Check you have php-pear and php-devel packages installed by this command. You must have these package installed
    1. # rpm -qa | grep -i php
    2. php-5.3.3-3.el6_1.3.x86_64
    3. php-cli-5.3.3-3.el6_1.3.x86_64
    4. php-devel-5.3.3-3.el6_1.3.x86_64
    5. php-common-5.3.3-3.el6_1.3.x86_64
    6. php-mysql-5.3.3-3.el6_1.3.x86_64
    7. php-soap-5.3.3-3.el6_1.3.x86_64
    8. php-pear-1.9.4-4.el6.noarch
    9. php-gd-5.3.3-3.el6_1.3.x86_64
  3.  Install oci8 installation# pecl install oci8
  4. if you unable to install above command, try to download latest version of PECL according to your PHP version
  5. create ‘src’ directory under /user/local
  6. use scp command#scp -r /Users/aoza002c/Desktop/CentOS/1/oci8-2.1.3/ cd /user/local/src/oci8-2.1.3
    #./configure –with-oci8=shared,instantclient,/usr/lib/oracle/12.1/client64/lib/
    #make install
  7. if you see below fatal error
    #export PHP_DTRACE=yes
  8. Add the folowing configuration at the end of php.ini#vi /etc/php.ini
  9. Restart Apache #service httpd restart

Below links for more reference:

Tags :

About the Author