How To Enable OCI8 on PHP 5.4 and Install Oracle Instant Client on Mac OS X 10.9 Maverick

After upgrading to OS X 10.9 Maverick, i’ve to reinstall PHP library and reconfigure it. Oracle OCI8 is one of PHP libraries which need to be reconfigured.

Today i spend more than 2 hours just to find out how to enable Oracle OCI8 in PHP 5.4.24. So I post it here just in case i have to reconfigure it again, i don’t have to feel the pain again.

Lets Start!

  1. Download Oracle Client Library from http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html
    You have to download 3 files:

    After downloading 3 files above, you have to extract instantclient-basic and instantclient-plus zip files into one folder, for example in “/Applications/instantclient”. And then create folder named “sdk” inside that folder, and extract instantclient-sdk into it.  And then add symbolic link using this command in Terminal:

    ln -s libclntsh.dylib.11.1 libclntsh.dylib

    Oracle Instant Client folder

    Oracle Instant Client folder (click picture to enlarge).

  2. Download oci8 tar PECL package from http://pecl.php.net/package/oci8
    After downloading package from pecl, extract it anywhere you like. And then open “Terminal” and go to that folder. Then run commands below.

    phpize
    ./configure --with-oci8=shared,instantclient,/Applications/instantclient
    make
    sudo make install

    Edit “/Applications/instantclient/” to the path where you extract Oracle Instant Client (point 1).

  3. Edit Apache plist file on /System/Library/LaunchDaemons/org.apache.httpd.plist
    Open Apache plist using text editor and then find Environment Key section. Add DYLD_LIBRARY_PATH key and your Oracle Instant Client folder as value.

    Editing Apache plist File

    Editing Apache plist File

  4. Open your /Users/yourusername/.bash_profile file using text editor, then add “export DYLD_LIBRARY_PATH=/Applications/instantclient/” (without quotes) at the end of file.
  5. Edit your php.ini and add “extension=oci8.so”
  6. Open terminal, and run this command : sudo apachectl restart
  7. Done! Open PHP Info

    oci8 has been installed

    oci8 has been installed

UPDATE:

If you still not getting it to work, check Sarah’s comment below.

8 thoughts on “How To Enable OCI8 on PHP 5.4 and Install Oracle Instant Client on Mac OS X 10.9 Maverick

  1. Sarah

    These instructions look great, but I’m still not getting it to work. Do you have any suggestions for testing at various steps to ensure that each works? Perhaps ‘what to expect’ after each step would help.
    I had to sudo a lot to get things to work (not just the one place where you said to sudo). This suggests that maybe I have a permissions issue, so I’m going to investigate that a bit. Any additional suggestions would be much appreciated.
    Surely there are more than 4 of us in the world trying to do this!!

    Reply
  2. Sarah

    Got it!! Just in case it helps someone else…
    The problem was that the versions didn’t match. I figured this out by running php from the command line. This gave me the error message.
    PHP 5.5.13 still uses OCI8 version 2.0.7. (I had assumed 2.0.8; you know what happens when you ass-u-me!)
    Thanks for this posting–it was a huge help.

    Reply
  3. Marco Todaro

    Great! But to make it all work I had to change my .bash_profile file as follows:

    export DYLD_LIBRARY_PATH=/Applications/instantclient/

    Anyway, thanks for the guide. Best Regards.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.