General => Gena01 Blog => Topic started by: Gena01 on January 03, 2008, 10:19:57 pm

Title: Installing Oracle Instant Client 11g and PECL OCI8
Post by: Gena01 on January 03, 2008, 10:19:57 pm
This is part 2 of my installation instructions. This is my attempt to provide an updated and simplified reference. I am leaving Part 1 ( as is, because that part can also be useful.

NOTE: I am running Mandriva 2008 release. So most of the relevant packages and commands are for Mandriva.

Installation of Oracle Instant Client 11g is quite similar to 10g except that 11g requires libaio1 to be installed. urpmi libaio1 (as root) worked for me.

1. Download the Oracle Instant Client for Linux rpms from ( The files that I am using and that you will need are:
NOTE: Don't get basic-lite as this won't install by itself and you won't be able to build the Pecl OCI extension.
3. Install libaio1 urpmi libaio1. NOTE: This is a new dependency for 11g.
4. Install those rpms to your linux system:
sudo rpm -ivh oracle-instantclient-*
NOTE: Here is where things get interesting. We need to prepare a couple of configuration files and you will need to become root in order to make those files usable on a global level.
5. You need to be root at this point:
sudo bash
6. Create /etc/oracle directory as this is where we will store Oracle configuration files.
7. You will also need to grab a copy of tnsnames.ora file either from your Oracle DBA or from another system.
copy tnsnames.ora /etc/oracle
8. Create a shell script that will initialize Oracle environment variables.
vi /etc/profile.d/
place the following into that file:

    export TNS_ADMIN=/etc/oracle/
    export SQLPATH=/usr/lib/oracle/
    export LD_LIBRARY_PATH=/usr/lib/oracle/$LD_LIBRARY_PATH
    export PATH=$PATH:$SQLPATH
9. This is pretty much it. When you logout and log back in you should confirm that your environment variables are there using
. Also try out sqlplus to make sure it works and can connect to your Oracle database.

Simplified Pecl OCI8 installation:
1. # pear install pecl/oci8
2. You will be prompted with an option to provide instant client lib directory:
   a. enter 1 - NOTE: Don't select autodetect as this never worked for me.
   b. enter instantclient,/usr/lib/oracle/
   c. press Enter to continue.
   d. It should build and install the
4. Create a file called /etc/php.d/999_oci.ini and place the following line there:
5. vi /etc/sysconfig/http and add the following lines at the very end of the file
      # Adding ORACLE Variables to the config status (cause during upgrade the httpd file got replaced :( )
      export TNS_ADMIN=/etc/oracle
6. service httpd restart
7. And you are done. Pull up a page that calls phpinfo() and confirm that oci8 is loaded in apache and that the environment variables are setup properly. You can also do "php -m" to see of php cli loads the module as well.

Also Rob Richard posted some of his notes battling SELinux while trying to install Oracle Instant Client and getting it to work with PHP. Read the article here (,-Oracle-and-SELinux.html)

Let me know how it works out for you.


Title: Re: Installing Oracle Instant Client 11g and PECL OCI8
Post by: Anonymous Poster on February 11, 2008, 02:02:08 pm
Great instructions!  FYI for Debian/Ubuntu users - step 5 in the section "Simplified Pecl OCI8 installation:" should reference editing /etc/apache2/envvars instead of /etc/sysconfig/http

Title: Re: Installing Oracle Instant Client 11g and PECL OCI8
Post by: Alex Gorbachev on February 25, 2008, 11:44:05 pm
Interesting why on earth would it require libaio on client side? Maybe "feature" of the first release?
Also, perhaps it's PECL specific, but for generic instant client you don't have to use /etc/oracle  and can use you local profile like ~/.profile. Do you?

Title: Re: Installing Oracle Instant Client 11g and PECL OCI8
Post by: Gena01 on February 25, 2008, 11:59:07 pm
1. rpms won't install without libaio1 present on the system.
2. /etc/oracle is there so that tnsnames.ora could be placed there and having TNS_ADMIN pointing at the tnsnames.ora globally so the Oracle names can be resolved for anybody. Also some of the other config files can also be placed there to debug or trace the Oracle client.

~/.profile is a login script, which is a bit different.