In some PHP projects, you could have to use an Oracle Database. In this case, you need install OCI8 module in your PHP configuration.

Install Oracle Client Instant & SDK

Download the latest Oracle Instant Client and SDK

Download the latest Oracle Instant Client and SDK from the Oracle website

https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html

You must find 2 packages :

  • Basic Package (like instantclient-basic-linux.x64-19.3.0.0.0dbru.zip)
  • SDK Package (like instantclient-sdk-linux.x64-19.3.0.0.0dbru.zip)

Move them into an new directory.

mkdir -p /opt/oracle
mv instantclient-basic-linux.x64-19.3.0.0.0dbru.zip /opt/oracle/.
mv instantclient-sdk-linux.x64-19.3.0.0.0dbru.zip /opt/oracle/.

Extract the files

cd /opt/oracle
unzip instantclient-basic-linux.x64-19.3.0.0.0dbru.zip
unzip instantclient-sdk-linux.x64-19.3.0.0.0dbru.zip

Add in the ldconfig's config folder

Now lets add the folder to the ldconfig's config folder.

echo /opt/oracle/instantclient_19_3 > /etc/ld.so.conf.d/oracle-instantclient.conf

Restart ldconfig

ldconfig

Add PHP's extension

Install packages

sudo apt install php-dev php-pear build-essential libaio1

Install the OCI8 extension via PECL

echo "instantclient,/opt/oracle/instantclient_19_3" | pecl install oci8

Load extension from php.ini

echo "extension=oci8.so" >> /etc/php/7.1/mods-available/oci8.ini

Restart & check

Restart PHP and check if OCI8 module is loaded in phpinfo.

Previous Post