OCI8 PHP5 Ubuntu

OCI8 is an extension for providing APIs to Oracle database management system. However, installing OCI8 is not just easy like apt-get since it requires SDK offered by Oracle and its distribution license prohibits the inclusion to linux distribution. That means we have to download and compile it by ourselves. Fortunately, it is a little bit easy for Ubuntu.

Install PEAR and PECL

sudo apt-get install php-pear
Download Oracle Instant Client. You need at least Basic and SDK.

Extract the archives.

sudo mkdir -p /opt/oracle
cd /opt/oracle
sudo unzip instantclient-basic-linux-x86-64-10.2.0.3-20070103.zip
sudo unzip instantclient-sdk-linux-x86-64-10.2.0.3-20070103.zip
sudo mv /opt/oracle/instantclient_10_2 /opt/oracle/instantclient
Create symbolic links.

cd /opt/oracle/instantclient
sudo ln -s libclntsh.so.10.1 libclntsh.so
sudo ln -s libocci.so.10.1 libocci.so
Add instant client to system ld.

sudo su -
echo /opt/oracle/instantclient > /etc/ld.so.conf.d/oracle-instantclient
Compile oci8.

sudo pecl install oci8
Enter instantclient,/opt/oracle/instantclient when you are prompted.

Enable the extension.

sudo su -
echo extension=oci8.so >> /etc/php5/apache2/php.ini
Restart apache2.

Refer : http://www.howforge.com

sudo /etc/init.d/apache2 restart