Friday 24 October 2008

How I got php with oci8 working

  1. Install Oracle instant client (the basic package and the SDK!). (You obviously need the 64bit version on a 64bit architecture). I tried doing this using my locally installed oracle express edition (XE) but that whas a whole lot of pain:
    OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME is set and points to the right directory
    I ended up using oracle_instantclient_10_2 which worked!!
  2. sudo -i
  3. apt-get install apache2 php5 php5-dev php-pear libaio1
  4. Make sure your $ORACLE_HOME and $LD_LIBRARY_PATH is set. Since I have 2 different versions of 'oracle' I set these two variables in /usr/sbin/apache2ctl, at the top of the 'CONFIGURATION SETION':
    export ORACLE_HOME=/stuph/install/oracle_instantclient_10_2
    export LD_LIBRARY_PATH=$ORACLE_HOME
  5. echo $ORACLE_HOME >> /etc/ld.so.conf
  6. ldconfig
  7. Check if the symlinks named libclntsh.so and libocci.so exist in $ORACLE_HOME, which we will need later. In my case these symlinks were not created by ldconfig, so I created them manually:

    ln -s libclntsh.so.11.1 libclntsh.so; ln -s libocci.so.11.1 libocci.so

  8. pecl install oci8
  9. To enable the oci8 module, add "extension=oci8.so" to /etc/php5/apache2/php.ini and /etc/php5/cli/php.ini). (put this line after the examples starting with ; in the "Dynamic Extensions" section).

  10. ldconfig
  11. apache2ctl restart
    (or
    /etc/init.d/apache2 force-reload
    to make sure)
  12. You should see the oci8 module in the output of phpinfo(). (put info.php in ~www-data or ~apache with the following content and browse to it: "<? phpinfo() ?>")

(I'm sorry if this assumes you know how to do certain stuff, but this is a howto for myself, so that I can remember how to do this in a mounth's time)

1 comment:

  1. Dude, I've been up and down google looking for a solution to the dreaded errmsg:

    OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME and LD_LIBRARY_PATH

    Step #4 actually solved this problem on my system. PHP+ORALCE11g+UBUNTU all on the same test box. THANKYOU!!!!

    ReplyDelete