Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tap52384/269d342da20e157d8d4dd0834f402eb5 to your computer and use it in GitHub Desktop.
Save tap52384/269d342da20e157d8d4dd0834f402eb5 to your computer and use it in GitHub Desktop.
Install OCI8 on OSX via Brew

Installation

This procedure is tested on Mac OS X 10.14.0 with Xcode Developer Tools installed (xCode).

PHP 5.6, 7.0, 7.1, and 7.2 installed with Homebrew following the instructions here.

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 the directory /usr/local/bin/:

cd ~/Downloads
unzip ~/Downloads/instantclient-basic-macos.x64-12.2.0.1.0-2.zip -d /usr/local/bin/
unzip ~/Downloads/instantclient-sqlplus-macos.x64-12.2.0.1.0-2.zip -d /usr/local/bin/
unzip ~/Downloads/instantclient-sdk-macos.x64-12.2.0.1.0-2.zip -d /usr/local/bin/

This will unzip all of the necessary files in the new /usr/local/bin/instantclient_12_2/ directory like so:

├
├── BASIC_README
├── SQLPLUS_README
├── adrci
├── genezi
├── glogin.sql
├── libclntsh.dylib.12.1
├── libnnz12.dylib
├── libocci.dylib.12.1
├── libociei.dylib
├── libocijdbc12.dylib
├── libons.dylib
├── liboramysql12.dylib
├── libsqlplus.dylib
├── libsqlplusic.dylib
├── ojdbc8.jar
├── sdk
│   ├── SDK_README
│   ├── demo
│   ├── include
│   ├── ott
│   └── ottclasses.zip
├── sqlplus
├── uidrvci
└── xstreams.jar

Create symlinks

ln -s /usr/local/bin/instantclient_12_2/sdk/include/*.h /usr/local/include/
ln -s /usr/local/bin/instantclient_12_2/sqlplus /usr/local/bin/
ln -s /usr/local/bin/instantclient_12_2/*.dylib /usr/local/lib/
ln -s /usr/local/bin/instantclient_12_2/*.dylib.12.1 /usr/local/lib/
ln -s /usr/local/lib/libclntsh.dylib.12.1 /usr/local/lib/libclntsh.dylib

Install extension with pecl

pecl install oci8-2.0.12 # PHP 5.2 - 5.6

pecl install oci8 # PHP 7+

If you get permissions errors, you may need to use sudo when installing with pecl.

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

instantclient,/usr/local/lib

If installation fails via PECL, you can install oci8 manually using the following at the terminal. Please note the version of oci8 that applies to your version of PHP:

cd ~
pear download pecl/oci8
tar xvzf oci8-2.1.8.tgz
cd oci8-2.1.8/
phpize
./configure --with-oci8=shared,instantclient,/usr/local/lib
make
make test
make install

The command make test is optional and not required for installation to work. It can be somewhat helpful if you run into errors.

And your are done, make sure the following line exists in your php.ini (mine is located at /usr/local/etc/php/7.0/php.ini):

extension=oci8.so

Restart your HTTP Server and test:

sudo apachectl -k stop
sudo apachectl -k start
@davidperezgar
Copy link

Not working the files from oracle links...

@JcGuerrero15
Copy link

Not working for me. I dont had any errors during the installation but when I run my web app I still have the error Uncaught Error: Call to undefined function oci_connect().

@Pedroletti-Michael
Copy link

Hey, just writing here because I had some issues with the installation. And for troubleshooting the problems I had to look for the path where the oci8.so (this info was find during the end of the command pecl install, it say something like "Libraries have been installed in : path) was installed and just copy the path to the php.ini on the line extension_dir="/path/to/oci8.so".

Have a nice day 👍

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