Install Oracle Extension OCI8 on Centos 6/7 – LAMPP/XAMPP Linux

This is the way can use to install PHP module extension OCI8 (Oracle) on Centos 6/7 with LAMPP or XAMPP Linux. For the first thing you will need install these prerequisites :


yum install php-pear
yum install php-devel


And you will have to download both of RPM Packages from Oracle Instant Client Download :

  1. oracle-instantclientXXX-basic-xxx.rpm
    This one contains additional header files and an example “makefile” for developing Oracle applications with Instant Client.
  2. oracle-instantclientXXX-devel-xxx.rpm
    This one contains files required to run OCI, OCCI, and JDBC-OCI applications.

notes : The XXX are for oracle instant client version and your platform, choose as you need.

I recommend you to place those files into same folder, and then install those file using rpm command. You need these files for import libraries. You can install by this command below :

rpm -ivh instantclientXXX-basic-xxx.rpm
rpm -ivh instantclientXXX-devel-xxx.rpm



PHP OCI8 extension from PECL is always with the current version. It’s important for you before installing OCI8, you have to check your PHP version in your server. You can check your PHP version by this command below :

php --version

And then you need to install OCI8 by this command :

// for PHP 7 or later use this
pecl install oci8

// for PHP 5.2 until PHP 5.6 use this
pecl install oci8-2.0.12

// for PHP 4.3.9 - PHP 5.1 use this
pecl install oci8-1.4.10

For more information about pecl oci8 installation you can check out from PECL PHP Packages here.

Wait for the download and installation process and may you observe the output carefully, make sure no errors. In installing process you will need to fill a config for your Oracle Client Library Path.
In my server it placed in /usr/lib/oracle/11.2/client64/lib/. You have to check your own path.

Example for oci8 installation process

My friend follow every steps above but he got an error like this :

checking Oracle ORACLE_HOME install directory... /usr/lib/oracle/11.2/client64/lib/
checking ORACLE_HOME library validity... configure: error: Expected an ORACLE_HOME top level directory but /usr/lib/oracle/11.2/client64/lib/ appears to be an Instant Client directory. Try --with-oci8=instantclient,/usr/lib/oracle/11.2/client64/lib/
ERROR: `/var/tmp/oci8/configure --with-oci8=/usr/lib/oracle/11.2/client64/lib/' failed

And the solution is very simple, use the script below to install oci8 extension
echo "instantclient,/usr/lib/oracle/11.2/client64/lib" | pecl install oci8-2.0.12

Well If any errors are shown, you have to review what the error said, just make sure you haven’t missed anything steps above. When oci8 is successfully installed, you now need to edit the php.ini config file to add the compiled (OCI8 Extension File) file :

nano /opt/lampp/etc/php.ini

Add this code into your end of line in your php.ini

Once you have add that code in your php.ini, the last step is restart your lampp server with this script.
/opt/lampp/lampp restart

And now check your phpinfo(). If your oci8 installed you will se like this one.

Leave a Reply