This procedure is tested on Mac OS X 10.12.6
PHP 7.2 installed with Homebrew.
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-2.zip
- instantclient-sqlplus-macos.x64-12.2.0.1.0-2.zip
- instantclient-sdk-macos.x64-12.2.0.1.0-2.zip
Create and unzip all theses files into a the directory /usr/local/instantclient/12.2.0.1/
.
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
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 yourphp.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...) !
I've tried, using the following steps:
Edit
/etc/profile
and add the following:Install OCI8. I'm using version 3.0.1 because I'm having PHP 8.0.13. If you are running on PHP 8.1, you don't need to provide the version.
And yes, having similar issue.
The only option for now is to run your application in Docker.