Saturday, March 20, 2010

Install PHP-Oracle bridge in Linux

Note: These instructions are for 32-bit ubuntu 9.0.4 machine. Make sure you download the appropriate packages according to system.

Install the instantclient and configure it

Download the Basic and the SDK packages for oracle from:

Now run the following commands on the shell. Descriptions for each command precede them:


Create a folder to unzip the files

# mkdir -p /opt/oracle/instantclient


Go to the created folder

# cd /opt/oracle/instantclient


Unzip the basic and sdk zip files

# unzip instantclient-basic-linux32-10.2.0.1-20050713.zip

# unzip instantclient-sdk-linux32-10.2.0.1-20050713.zip

Add instant-client information to ldconfig

# echo /opt/oracle/instantclient/instantclient_10_2 >> /etc/ld.so.conf

# ldconfig


Go to the unzipped instantclient folder

# cd /opt/oracle/instantclient/instantclient_10_2


Manually create symlinks named libclntsh.so and libocci.so as mentioned below.

# ln -s libclntsh.so.10.1 libclntsh.so

# ln -s libocci.so.10.1 libocci.so


Download the oci8 module with pear.

Pear is in the php5-pear package. You need php5-dec package for phpize

# sudo apt-get install php5-pear php5-dev

Create a folder to install oci8

# mkdir -p /usr/local/src

Change to the created folder

# cd /usr/local/src

Download the oci8 module

# wget http://pecl.php.net/get/oci8-1.3.5.tgz


Extract the tar contents

# tar xzvf oci8-1.3.5.tgz

Change to the extracted folder

# cd oci8-1.3.5

Run phpize

# phpize

Configure oci8 with instantclient, make and make install

# ./configure --with-oci8=shared,instantclient,/opt/oracle/instantclient/instantclient_10_2/

# make

# make install


To enable the oci8 module for php, edit /etc/php5/apache2/php.ini

and put this line after the examples starting with ;extension

[OCI8]

extension=oci8.so

Restart Apache.

# sudo service apache2 restart

You should be able to see the oci8 module in the output of phpinfo().

No comments:

Post a Comment