Instantly share code, notes, and snippets.

What would you like to do?
install Oracle PHP Extension (oracle OCI8) - instantclient for Mac OS 10.8 - homebrew environnement


This procedure is tested on Mac OS X 10.8 with Developpers tools installed (xCode).

PHP 5.4 installed with Homebrew.

Update: I wrote a blog post about this.


Download the following files from Oracle website (yes, you need to create an account and accept terms):

Create and unzip all theses files into a the directory /usr/local/instantclient/ This directory will looks like:

├── adrci
├── genezi
├── glogin.sql
├── libclntsh.dylib.11.1
├── libnnz11.dylib
├── libocci.dylib.11.1
├── libociei.dylib
├── libocijdbc11.dylib
├── libsqlplus.dylib
├── libsqlplusic.dylib
├── ojdbc5.jar
├── ojdbc6.jar
├── sdk
│   ├── SDK_README
│   ├── demo
│   ├── include
│   ├── ott
│   └──
├── sqlplus
├── uidrvci
└── xstreams.jar

Create symlinks

   ln -s /usr/local/instantclient/*.h /usr/local/include/
   ln -s /usr/local/instantclient/ /usr/local/bin/
   ln -s /usr/local/instantclient/*.dylib /usr/local/lib/
   ln -s /usr/local/instantclient/*.dylib.11.1 /usr/local/lib/
   ln -s /usr/local/lib/libclntsh.dylib.11.1 /usr/local/lib/libclntsh.dylib

Test with sqlplus instantclient

I recommand to install Oracle Server with a VirtualBox VM preinstalled.

   /usr/local/bin/sqlplus oracle/oracle@

Install extension with pecl

   pecl install oci8

If the script prompt you to provide the path to ORACLE_HOME directory, respond with:


And your are done, normally pecl will automatically load the extension in your php.ini. If not, add the following line to your php.ini:

Restart your HTTP Server and test.

Enjoy (or try to...) !


This comment has been minimized.

rkempter commented Mar 25, 2013

  • ln -s /usr/local/instantclient/ /usr/local/includes/ -> ln -s /usr/local/instantclient/ /usr/local/include/
  • /usr//local/bin/sqlplus scott/tiger@myoracle -> /usr/local/bin/sqlplus scott/tiger@myoracle and password didn't work for me

This comment has been minimized.

wenbin1989 commented Nov 14, 2014

Your oci8 extension may only show in commond line by using "php -m" but doesn't show on the webpage by "phpinfo()". So that you still can't connect to oracle.

Solution: sudo vi /System/Library/LaunchDaemons/org.apache.httpd.plist

This plist is apache used to load all the environment variables. Add ORACLE_HOME, DYLD_LIBRARY_PATH, LD_LIBRARY_PATH into this plist. And then restart apache server.
The plist should look like the following.

<?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
  <plist version="1.0">


This comment has been minimized.

krismp commented Jul 22, 2015

php -m listed the oci8 extension but not in the phpinfo(). And I try this solution:

sudo vi /System/Library/LaunchDaemons/org.apache.httpd.plist

but still not working :(


This comment has been minimized.

calmdev commented Nov 5, 2015

These instructions have always worked for me until upgrading to El Capitan. After upgrading I kept running into the same issue as described above by @krismp. The only way I was able to resolve this was by disabling the system integrity protection as described here before trying to edit the plist as described above by @wenbin1989. After doing that everything works perfectly with apache and OCI8 is showing in the output of phpinfo(); Without first disabling S.I.P. the OS would not accept any changes to permissions or edits to the apache plist file.


This comment has been minimized.

apit commented Jan 1, 2016

disabling SIP and adding paths to plist didnt work for me. instead, i symlink-ing all instantclient dylibs into /homebrew-root/Cellar/httpd24/2.4.16/lib/


This comment has been minimized.

the7th commented May 9, 2016


This comment has been minimized.

XavRsl commented May 13, 2016

Just a note for my futur self (and others). If using only php (no nginx or httpd), you may add env vars to php plist file, adding them to php-fpm.conf doesn't seem to work. Here's how :

file ~/Library/LaunchAgents/homebrew.mxcl.php70.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

This is how you would make Oracle DB work with Laravel Valet that uses php server capabilities on a php-fpm brew install.



This comment has been minimized.

jalex19100 commented Jun 17, 2016

You do not need to edit the plist to add environment variables to Apache. Use "SetEnv ORACLE_HOME ..." in the httpd.conf. Trying to work around SIP isn't even necessary.


This comment has been minimized.

rafaelgrube commented Jul 15, 2016

I tried the test from sqlplus, but always I received the ERROR: ORA-21561: OID generation failed. I looked on the internet and most of people said this is a problem with my hosts file. But I tried with IP and a received the same error. Any tip for this?

/usr/local/bin/sqlplus user/password@


This comment has been minimized.

mrbrownisintown commented Jul 28, 2016

I've installed oracle instant client on El Capitan and am up and running, but it took me quite a part of the day...

For oracle instant client version on El Capitan, the symlinks are slightly different:

sudo mkdir /usr/local/instantclient
sudo mkdir /usr/local/instantclient/
sudo ln -s /usr/local/instantclient/*.h /usr/local/include/
sudo ln -s /usr/local/instantclient/ /usr/local/bin/
sudo ln -s /usr/local/instantclient/*.dylib /usr/local/lib/
sudo ln -s /usr/local/instantclient/*.dylib.12.1 /usr/local/lib/
sudo ln -s /usr/local/lib/libclntsh.dylib.12.1 /usr/local/lib/libclntsh.dylib

A couple things I've found:

sudo pecl install -f oci8-2.0.11

  • phpize didn't seem to work, check below how to check this (it didn't show PHP Api version etc), so I had to install/update xcode command line: xcode-select --install

running: phpize
grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:


This comment has been minimized.

andreecy commented Nov 16, 2017

thaaank you so much! work for me on Sierra

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment