Adding the Oracle extension (oci8) to MAMP PRO 3/OS X 10.9

I’ve never been successful in getting the OCI8 extension working on OS X (with or without MAMP) until now. I’ve been forced to use Vagrant (which is a usually a good thing) for anything requiring an Oracle connection).



Make sure that the PHP version you are using in MAMP is in your path:
export MAMP_PATH=/Applications/MAMP/bin/php/php5.4.26/bin
export PATH=$MAMP_PATH:$PATH:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:~/composer-packages/vendor/bin

Download the basic and SDK packages.

Extract the files into a common folder (i.e.,/opt/oracle/instantclient). unzip *\.zip. They will all end up in a instantclient_11_2 folder, which I renamed to just instantclient. create two symbolic links:

ln -s libclntsh.dylib.11.1 libclntsh.dylib ln -s libocci.dylib.11.1 libocci.dylib

Download the source for the version of php that you are using in MAMP (I’m using 5.4.26).

Extract the PHP source file and move the created folder to the following location (based on PHP version): /Applications/MAMP/bin/php/php5.4.26/include/php. The contents of the extracted folder should be in the root of ../include/php.

Run sudo pecl install oci8 from anywhere.

For the oracle instant client path, use: instantclient,/opt/oracle/instantclient. If all goes well, the last line of the build process should say: You should add "" to php.ini In MAMP, go to File | Edit Template, choose your PHP version and add the above text where appropriate.

Open /Applications/MAMP/Library/bin/envvars and add the path to the instant client library: DYLD_LIBRARY_PATH="/opt/oracle/instantclient:/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"

Restart MAMP and go to the MAMP welcome page and open up phpinfo and see if there is an entry for OCI8. Done. Credit to for filling in a few missing pieces for me (downloading the source for the PHP version used in MAMP and edting the envvars file). For the other steps, the main difference for me is the preference of keeping the oracle library files in /opt/oracle like I would on an Ubuntu server.

comments powered by Disqus