Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Install OCI8 and / or PDO_OCI on OSX via Brew


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

PHP 5.6 installed with Homebrew.


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

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.11.1 /usr/local/lib/
sudo 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.

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

Install extension with pecl

sudo pecl install oci8-2.0.10 # phpv5.2 - phpv5.6

sudo pecl install oci8 # phpv7

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


Note: If you got PECL error:

touch $(brew --prefix php52)/lib/php/.lock && chmod 0644 $(brew --prefix php52)/lib/php/.lock # phpv5.2

touch $(brew --prefix php56)/lib/php/.lock && chmod 0644 $(brew --prefix php56)/lib/php/.lock # phpv5.6

touch $(brew --prefix php70)/lib/php/.lock && chmod 0644 $(brew --prefix php70)/lib/php/.lock # phpv7

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.

To installing pdo_oci. You must do following command:

mkdir -p /usr/local/lib/oracle/
ln -sf /usr/local/instantclient/ /usr/local/lib/oracle/
cd /tmp
pecl download pdo_oci
tar -xvf PDO_OCI-1.0.tgz
cd PDO_OCI-1.0

After that, download this patch and apply:

patch config.m4 < config.m4.patch

Also, we need to patch pdo_oci.c file:

patch pdo_oci.c < pdo_oci.c.patch

We should tell our configuration to use version, so it will find the right version in our system.

./configure --with-pdo-oci=instantclient,/usr/local/lib,

Build it and install it:

make install

After this open your php.ini and add this line:

Test it!

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