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.
Download the following files from Oracle website (yes, you need to create an account and accept terms):
- instantclient-basic-macos.x64-12.2.0.1.0.zip
- instantclient-sqlplus-macos.x64-12.2.0.1.0.zip
- instantclient-sdk-macos.x64-12.2.0.1.0.zip
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
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
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
Not working the files from oracle links...