acloudtree

Ubuntu 7.10 + oci8 + PHP5

A while ago I posted on the ubuntu forums a tutorial that I had written. This tutorial covers how to compile oci8 lib with php5 on Ubuntu 7.10. I figured I would post it on the site and get some feed back. For this edition it is assumed that you are issuing these commands from the command line.

Login to a Terminal and issue a sudo -i
# sudo -i

Install Apache2
# apt-get install apache2

Install required PHP5 modules and libraries
# apt-get install php5-common php5 php5-dev libapache2-mod-php5 php5-cli

Install the build-essential and php-pear packages
# apt-get install build-essential php-pear

IMPORTANT! Install libaio1 library. This is what I was having serious issues with originally.
# apt-get install libaio1

Download the new Instantclient and SDK zip files from Oracle.

link

In my case the files are called Basic.zip and Sdk.zip Initially these files will be saved in my home directory under the Documents folder
/home/ubuntu/Documents/

create a directory to house the zip files once they are uncompressed
# mkdir /opt/oracle

move the .zip files in the “Documents” directory to the /opt/oracle directory
# mv /home/ubuntu/Documents/*.zip /opt/oracle

Change to the /opt/oracle directory
# cd /opt/oracle

Unzip the files
# unzip \*.zip

rename instantclient directory
# mv instantclient_11_1 instantclient

Change directory to instantclient, list the files
# cd instantclient

Create symbolic links
# ln –s libclntsh.so.11.1 libclntsh.so
# ln –s libocci.so.11.1 libocci.so

Create a source directory under /opt/oracle . This is where we will house the oci8 libraries.
# mkdir /opt/oracle/src

Change the directory to /opt/oracle/src and download the oci8 tar using pecl
# cd /opt/oracle/src

# pecl download oci8

Untar the oci8 libraries
# tar xvf oci8-1.2.4.tgz

Change to the newly created oci8-1.2.4 directory and issue the following commands
# cd oci8-1.2.4

# phpize

Set the ORACLE_HOME environment variable
# export ORACLE_HOME=/opt/oracle/instantclient

# echo $ORACLE_HOME
/opt/oracle/instantclient

Configure oci8 to install with the necessary parameters
# ./configure --with-oci8=share,instantclient,/opt/oracle/instantclient

run make to compile
# make

install oci8
# make install

insert the extension=oci8.so into the php.ini and cli.ini files
# echo extension=oci8.so >> /etc/php5/apache2/php.ini
# echo extension=oci8.so >> /etc/php5/cli/php.ini

restart apache
# /etc/init.d/apache2 restart

create a phpinfo.php file in /var/www
# vi /var/www/phpinfo.php

Now go to your browser and run the phpinfo file and look for the oci8 module

http://localhost/phpinfo.php

Download my oratest php template file and configure it with the needed settings.

Test the connection
# php /home/ubuntu/oratest.php
Connection Succesful

3 comments

  1. Josef Stich says:

    Hi!

    Nice tutorial, it worked.

    But you have an error in the oratest php template.

    On line 13 you have

    if (!ora_conn){

    which should be

    if (!$ora_conn){

  2. Steve Blair says:

    This tutorial just saved me at _LEAST_ a week.

    Thank you, immensely.

  3. Maciek says:

    after 2 days …. i find YOUR tutorial. First work!!!

    thank u much

Post a comment

Copyright © Jared Folkins
Programming, Computers, Writing, Economics, and Life

Powered by WordPress