Installing php-oci8 with Oracle-XE in Ubuntu 10.04 x86-64

If you are using Oracle-XE for database with Apache and PHP you need to install php-oci8 module. It is difficult to find any .deb for php-oci8 which would run with PHP 5.3 and Oracle-XE. Somehow they dont like each other. Also, if you try to compile using pecl, it throws up errors. To work around this problem, you need to download and install Oracle Instant Client Basic 11g and then compile php-oci8 using pecl. Once you install Oracle Instant Client Basic 11g, the installation of php-oci8 becomes fairly simple.

Download the Oracle Instant Client Basic 11g from the Oracle website. Generally all firefox downloads are in the Downloads folder. Now, we need to extract the file into /opt

sudo  unzip ~/Downloads/ -d /opt

Now, install pecl using the following command

sudo apt-get install php-pear

After installation, use the following command to install php-oci8. Note: you must have php-dev and php-cli installed.

sudo pecl install php-oci8

After customary config checks, it will ask you for the oracle installation path. set the path manually to /opt/oracle/instantclient_11_2 in the following way


Thats it. php-oci8 will be installed. Now you can use Oracle-XE with php-oci8 in Ubuntu 10.04.


After installing, create a new file oci8.ini in /etc/php5/conf.d/ and in that add the following


This same procedure will work in Fedora 12 and above , except ,you will have to create the oci8.ini file in /etc/php.d/ instead.


Leave a Reply

Scroll to Top