Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cairocoder/57c5b51885e0aef088d5b2ebd6468369 to your computer and use it in GitHub Desktop.
Save cairocoder/57c5b51885e0aef088d5b2ebd6468369 to your computer and use it in GitHub Desktop.
How to install Oracle OCI8 Driver on Mac OSX with MAMP

Install Oracle OCI Driver OSX / MAMP

Go to https://www.oracle.com/database/technologies/instant-client/macos-intel-x86-downloads.html

Download the following zip files according to the required version

instantclient-basic-macos.x64-19.8.0.0.0.zip
instantclient-sqlplus-macos.x64-19.8.0.0.0.zip
instantclient-sdk-macos.x64-19.8.0.0.0.zip

Unzip the content of the three zip files, for example on the Downloads folder ~/Downloads/instantclient_19_8

In this case I'm using MAMP with PHP 7.4.12:

So the path I'm using is /Applications/MAMP/bin/php/php7.4.12

Copy all the content of ~/Downloads/instantclient_19_8 to /Applications/MAMP/bin/php/php7.4.12/lib/php/instantclient_19_8

Then install/compile oci8 with pecl

cd /Applications/MAMP/bin/php/php7.4.12/bin
sudo ./pecl install oci8-2.2.0 --with-oci8=instantclient,/Applications/MAMP/bin/php/php7.4.12/lib/php/instantclient_19_8

If prompted for the "Please provide the path to the ORACLE_HOME directory" just type:

instantclient,/Applications/MAMP/bin/php/php7.4.12/lib/php/instantclient_19_8

If evethings goes well it shows a message like this:

Build process completed successfully
Installing '/Applications/MAMP/bin/php/php7.4.12/lib/php/extensions/no-debug-non-zts-20190902/oci8.so'
install ok: channel://pecl.php.net/oci8-2.2.0
configuration option "php_ini" is not set to php.ini location
You should add "extension=oci8.so" to php.ini

Manually enable oci8 extension in the php.ini file

vim /Applications/MAMP/bin/php/php7.4.12/conf/php.ini
# Then add extension="oci8.so" to the file

extension="oci8.so"

Save the php.ini file and restart MAMP

If you look on MAMP PHP Info you should be able to see OCI8 Driver Available:

OCI 8 Driver MAMP

Based on

http://tomytree22.blogspot.com/2014/09/oci-driver-installation-on-mac.html

https://gist.github.com/gido/5237100

https://support.plesk.com/hc/en-us/articles/213409029-How-to-enable-Oracle-OCI8-extensions-for-Plesk-PHP-7

PDO OCI

In my particular case, I'm using Yii2 Framework I've looking for PDO OCI for develop with MAMP AND PHP 7.4.2, but it has been a difficult task, finally after searching in a lot of Google results, there's a related issue of this in Yii2 Repository and there's a comment that suggest few composer extensions to emulate PDO OCI, I tried https://www.yiiframework.com/extension/yii2-osi8pdo and it's working as expecetd on my dev environment

As @samdark suggested, there are more

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