Skip to content

Instantly share code, notes, and snippets.

@thattejada
Last active April 26, 2023 11:50
Show Gist options
  • Save thattejada/d15f0f0aad960eb7c4761fd03001602a to your computer and use it in GitHub Desktop.
Save thattejada/d15f0f0aad960eb7c4761fd03001602a 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

@cairocoder
Copy link

Amazing and straight forward step by step installation.

@dualklip
Copy link

Awesome tutorial! Thank you for the contribution

If somebody gets this message

Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

You can run this command to solve it
brew install autoconf automake libtool

@gamagamol
Copy link

hello i have try to follow you toturial but i have steel problem the oci not show when i access php info please help me

@gamagamol
Copy link

image

@JcGuerrero15
Copy link

image

Same problem here. Any solution? I dont had any errors on the installation but not work on my apache.

@thaanu
Copy link

thaanu commented Apr 26, 2023

Hi

Are you using M2 or M1? I came across this page, which says there is a bug in M1 macbooks. I am using a M2 Macbook Air and I am also stuck at where you are at.

Have tried reinstalling oci8, but still MAMP unable to pickup oci8.so

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