Thursday, September 3, 2009

How to install oci8(Oracle database) for php 5 and ubuntu 8.10

1. Install the Oracle Instant Client
  1. Download the Basic and SDK zip files from the official Oracle website.
  2. Create the following directory to store the instant client files
    /opt/oracle/instantclient/
  3. Unzip the basic.zip file into the above directory
  4. Create the following directory to store the sdk files
    /opt/oracle/instantclient/sdk/
  5. Unzip the sdk.zip file into the above directory
  6. Create the following two symbolic links
    1. ln -s libocci.so.11.1 libocci.so
    2. ln -s libclntsh.so.11.1 libclntsh.so

2. Install the oci8 module

For some reason on my system the automated build process failed.

This is an automated way of building and installing the module.

  1. Run the command to download and build the module
    sudo pecl install oci8
  2. When prompted enter the location of the instant client libraries
    instantclient,/opt/oracle/instantclient
  3. Congratulations, the library should now be installed
  4. Follow steps 14 and 15 to check that it is loading correctly. If it isn’t you may need to do steps 10 – 13 as well

If the automated script fails to find the instant client libraries follow this procedure

  1. Abort the automated build process Ctrl-C
  2. Change to the following directory
    /tmp/pear/download
  3. Copy the oci8-1.3.4.tgz to a suitable location, such as a sub directory in your home directory
    Note: the file name may be different depending on the version of the of the module
  4. Extract the contents of the file
    tar -xzf oci8-1.3.4.tgz
  5. Change into the new directory
    cd oci8-1.3.4
  6. Prepare the source code for building by executing this command
    phpize
  7. Configure the source code for building by executing the following command
    ./configure –with-oci8=shared,instantclient,/opt/oracle/instantclient
  8. Build the module by executing the following command
    make
  9. Install the newly built software
    sudo make install
  10. Change to the PHP 5 config directory
    cd /etc/php5/conf.d
  11. Open a new file in VI for editing
    sudo vi oci8.ini
  12. Add the following line to the file
    extension=oci8.so
  13. Write the file and quit VI
  14. Restart the Apache2 server
    sudo /etc/init.d/apache2 restart
  15. Check to ensure the module is loading using the phpinfo() function
thanks

No comments:

Post a Comment