If you are planning on using the oracle functions in PHP, you will need to install OCI8. Before you begin you will need to create an account with oracle or have access to the instant client basic install file and sdk file for your linux architecture.

Prerequisites for installing OCI8

  • sudo (you will be doing the command line parts as sudo).
  • An account on the oracle  website so you can download the instant client files.
  • A working Apache and PHP installation.

Installing the Oracle Instant Client Files

  1. Download the Oracle Instant Client for Linux (Both the Basic and SDK versions) from here.  Make sure you choose the correct architecture for your Ubuntu installation (32bit is x86, 64bit is x86_64).
  2. Copy the files just downloaded to your Ubuntu server using scp or the WinSCP application for windows.
  3. ssh into your ubuntu server using your favorite ssh client
  4. Install PECL, PHP Development files, Build Essential, Unzip, and the AIO Library
    apt-get install php-pear php5-dev build-essential unzip libaio1
  5. Create the oracle directory
    mkdir /opt/oracle
  6. Move the downloaded files
    mv instantclient-* /opt/oracle
  7. Unzip the files using the unzip command (unzip <filename>)
  8. Rename the created directory
    mv instantclient_11_2 instantclient
  9. cd into the instant client directory and create the following soft links
    ln -s libclntsh.so.11.2 libclntsh.so
    ln -s libocci.so.11.2 libocci.so
  10. cd to  /opt
  11. set the permissions on the directory
    chown -R root:www-data /opt/oracle
  12. Add the instant client to the the ld config files
    echo /opt/oracle/instantclient > /etc/ld.so.conf.d/oracle-instantclient
  13. Update the Dynamic Linker Run-Time Bindings
    ldconfig

Installing OCI 8 and Configuring Apache

  1. Install OCI8 using PECL
    pecl install 0ci8
  2. When you are pompted for the client location enter the following:
    instantclient,/opt/oracle/instantclient
  3. Add the extension to the php.ini files
    echo extension=oci8.so >> /etc/php5/apache2/php.ini
    echo extension=oci8.so >> /etc/php5/cli/php.ini
  4. Restart Apache
    /etc/init.d/apache2 restart
  5. Verify the installation of the OCI8 library by creating a simple phpinfo page.
    touch info.php; echo "<?php phpinfo(); ?>" > info.php
  6. Navigate to the page using your favorite web browser and confirm the OCI8 section is present.
About these ads