This guide refers to Instantclient Version 12.2.0.1.0
Download the latest Oracle Instant Client and SDK from the Oracle website (Yeah, fuck you Oracle, you need to create an account to download the files).
http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
Look for instantclient-basic-linux.x64-12.2.0.1.0.zip and instantclient-sdk-linux.x64-12.2.0.1.0.zip.
Create a new folder to store the Oracle Instant Client files on your machine.
mkdir /opt/oracleAnd move your files to /opt/oracle.
Extract the files
cd /opt/oracle
unzip instantclient-basic-linux.x64-12.2.0.1.0.zip
unzip instantclient-sdk-linux.x64-12.2.0.1.0.zipNext, we need to symlink the .so files.
ln -s /opt/oracle/instantclient_12_2/libclntsh.so.12.2 /opt/oracle/instantclient_12_2/libclntsh.so
ln -s /opt/oracle/instantclient_12_2/libocci.so.12.2 /opt/oracle/instantclient_12_2/libocci.soNow lets add the folder to the ldconfig's config folder.
echo /opt/oracle/instantclient_12_2 > /etc/ld.so.conf.d/oracle-instantclient.confAnd update the dynamic linker runtime bindings.
ldconfigGreat! We're almost there!
To install the OCI8 extension, we need to get some additional packages.
Run these commands to install the necessary packages:
apt install php-dev php-pear build-essential libaio1Install the oci8 extension via PECL.
echo "instantclient,/opt/oracle/instantclient_12_2" | pecl install oci8We now can tell PHP to load the OCI8 extension.
echo "extension=oci8.so" >> /etc/php/7.1/mods-available/oci8.ini
ln -s /etc/php/7.1/mods-available/oci8.ini /etc/php/7.1/cli/conf.d/20-oci8.ini
ln -s /etc/php/7.1/mods-available/oci8.ini /etc/php/7.1/fpm/conf.d/20-oci8.iniCheck if the extension is enabled.
php -m | grep oci8
php-fpm7.1 -m | grep oci8If you see oci8, you're almost done!
Restart PHP-FPM.
service php7.1-fpm restartFinished! Well done! Thanks for pulling through with this tedious procedure!
This was really handy, thanks! In case anyone else has the same problem, in Ubuntu 17.10 I needed step 5 to generate a file with a ".conf" suffix, otherwise ldconfig didn't notice it. (I also needed to manually install libaio1 to actually make things work).