[Gena01 Logo]
December 26, 2024, 08:01:33 pm *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Tags Login Register  
Pages: [1]
  Print  
Author Topic: Installing Oracle Instant Client 11g and PECL OCI8  (Read 105174 times)
0 Members and 1 Guest are viewing this topic.
Gena01
Administrator
Sr. Member
*****
Posts: 423



WWW
« 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 (http://www.gena01.com/forum/gena01_blog/installing_oracle_instant_client_and_making_it_work_with_php-t184.0.html) 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 http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html (http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html). The files that I am using and that you will need are:
Code:
      oracle-instantclient-sqlplus-11.1.0.1-1
      oracle-instantclient-devel-11.1.0.1-1
      oracle-instantclient-basic-11.1.0.1-1
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:
Code:
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:
Code:
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.
Code:
copy tnsnames.ora /etc/oracle
8. Create a shell script that will initialize Oracle environment variables.
Code:
vi /etc/profile.d/oracle.sh
place the following into that file:
Code:
 
    export TNS_ADMIN=/etc/oracle/
    export SQLPATH=/usr/lib/oracle/10.2.0.3/client/bin
    export LD_LIBRARY_PATH=/usr/lib/oracle/10.2.0.3/client/lib:$LD_LIBRARY_PATH
    export PATH=$PATH:$SQLPATH
    export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
9. This is pretty much it. When you logout and log back in you should confirm that your environment variables are there using
Code:
export
. 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/11.1.0.1/client/lib
   c. press Enter to continue.
   d. It should build and install the oci.so.
4. Create a file called /etc/php.d/999_oci.ini and place the following line there:
Code:
      extension=oci8.so 
5. vi /etc/sysconfig/http and add the following lines at the very end of the file
Code:
      ###
      #
      # Adding ORACLE Variables to the config status (cause during upgrade the httpd file got replaced :( )
      #
      export TNS_ADMIN=/etc/oracle
      export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
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 (http://www.cdatazone.org/index.php?/archives/37-PHP,-Oracle-and-SELinux.html)

Let me know how it works out for you.

Gena01
« Last Edit: October 07, 2008, 04:00:47 pm by Gena01 » Logged
Anonymous Poster
Guest
« Reply #1 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
Logged
Alex Gorbachev
Guest
« Reply #2 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?
Logged
Gena01
Administrator
Sr. Member
*****
Posts: 423



WWW
« Reply #3 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.

Gena01
Logged
Tags: PHP Oracle Pecl Oracle Instant Client 
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines | Sitemap Valid XHTML 1.0! Valid CSS!