There are frustratingly few tutorials on how to do this installation, which has lead to many a headache when installing this on new servers.
So, here's a quick rundown on how to get this installed on a ubuntu 20.04 server.
EDIT: I don't own a mac...
...but the commands should be very similar. At the very least, a quick google will turn up some tutorials on installing the prerequisites.
You may also need to figure out the different php installation locations (/etc/php is for linux)
Here's a tutorial on php extension installations for some of those details: https://affinitybridge.com/blog/adding-php-extensions-system-php-under-os-x-1015-catalina
note that you might be using different instantclient and PHP versions
prerequisites:
apt-get install unzip php-pear php7.4-dev
- Download the instantclient from oracle. https://www.oracle.com/database/technologies/instant-client/downloads.html. You're looking for the 'basic' and the 'sdk' downloads for your system/version
- unzip those into a directory. I'm using /opt/oracle.
unzip /instantclient-basic.zip -d /opt/oracle
unzip /instantclient-sdk.zip -d /opt/oracle
- symlink libraries
ln -s /opt/oracle/instantclient_11_2/libclntsh.so.11.1 /opt/oracle/instantclient_11_2/libclntsh.so
ln -s /opt/oracle/instantclient_11_2/libocci.so.11.1 /opt/oracle/instantclient_11_2/libocci.so
- make sure the oci.ini file exists in the mods-available directory
echo 'extension=oci8.so' > /etc/php/7.4/mods-available/oci.ini
- symlink the extension files.
ln -s /etc/php/7.4/mods-available/oci.ini /etc/php/7.4/cli/conf.d/10-oci8.ini
ln -s /etc/php/7.4/mods-available/oci.ini /etc/php/7.4/fpm/conf.d/10-oci8.ini
- define the required environment variables
ORACLE_HOME=/opt/oracle/instantclient_11_2/
LD_LIBRARY_PATH=/opt/oracle/instantclient_11_2/
- install the extension
echo "instantclient,$ORACLE_HOME" | pecl install oci8-2.2.0
- make sure ld knows about oracle
echo $ORACLE_HOME > /etc/ld.so.conf.d/oracle-instantclient.conf
ldconfig
- clean up
rm -rf /instantclient-*.zip \
The problem I consistently got hung up on was related to only setting up the extension for php cli OR php fpm and not both. If you don't set it up for both, you'll see the OCI constant error somewhere.
SO, don't skip step 5. ;)
PS If you find yourself getting hung up on something, lets work together and update this answer so we can all be happier about installing this extension.