Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save nasrulhazim/308c9f59a2ddba364b4b908ee9238265 to your computer and use it in GitHub Desktop.
Save nasrulhazim/308c9f59a2ddba364b4b908ee9238265 to your computer and use it in GitHub Desktop.
install Oracle PHP Extension (oracle OCI8) - instantclient for Mac OS 10.12.6 - homebrew environnement - on PHP 7.2

Installation

This procedure is tested on Mac OS X 10.12.6

PHP 7.2 installed with Homebrew.

Preparation

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/12.2.0.1/.

Create symlinks

sudo ln -sfn /usr/local/instantclient/12.2.0.1/sdk/include/*.h /usr/local/include/
sudo ln -sfn /usr/local/instantclient/12.2.0.1/sqlplus /usr/local/bin/
sudo ln -sfn /usr/local/instantclient/12.2.0.1/*.dylib /usr/local/lib/
sudo ln -sfn /usr/local/instantclient/12.2.0.1/*.dylib.12.1 /usr/local/lib/
sudo ln -sfn /usr/local/lib/libclntsh.dylib.12.1 /usr/local/lib/libclntsh.dylib

Install extension with pecl

pecl install oci8

On success installation, you will have messages like the following:

Build process completed successfully
Installing '/usr/local/Cellar/php/7.2.7/pecl/20170718/oci8.so'
install ok: channel://pecl.php.net/oci8-2.1.8
Extension oci8 enabled in php.ini

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

instantclient,/usr/local/lib

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:

Run php --ini to check your php.ini file location.

extension=oci8.so

Then do test the setup by running php -v.

If you are having error code like the following:

Warning: PHP Startup: Unable to load dynamic library 'oci8.so' (tried: /usr/local/Cellar/php/7.2.7/lib/php/20170718/oci8.so (dlopen(/usr/local/Cellar/php/7.2.7/lib/php/20170718/oci8.so, 9): image not found), /usr/local/Cellar/php/7.2.7/lib/php/20170718/oci8.so.so (dlopen(/usr/local/Cellar/php/7.2.7/lib/php/20170718/oci8.so.so, 9): image not found)) in Unknown on line 0

You can copy the oci8.so generated to the target path. In above case as following:

cp /usr/local/Cellar/php/7.2.7/pecl/20170718/oci8.so /usr/local/Cellar/php/7.2.7/lib/php/20170718/

Then you should see no more error message when runninng php -v.

Restart your HTTP Server and test.

Enjoy (or try to...) !

@abdulwahhabkhan
Copy link

Hi tried to install and everything look working except.

php -m

image

php -i

image

any idea what can be the reason?

Install oracle client and sqlplus user/password@localhost/service working.

@oldevill14
Copy link

@akhiidwandhare @abdulwahhabkhan

Mac OS current version is also not available to me.

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