Oracle Instant Client setup in Ubuntu
While working with my team, all dependencies in web server were managed by the system guys and we had nothing to worry about the dependencies. But recently I was working on a personal project and I had to manage all the dependencies of the web server myself. I was working with PHP 7.0 and Oracle in an Ubuntu machine. While connecting to Oracle server, an instant client is required to connect. I went through many tutorials and finally was able to get the system up and running. Here is the summarized steps that might help setting up Instant Client in Ubuntu machine.
Process
Install Ubuntu server and the system.
$ sudo apt-get update
Install Apache server and PHP 7.0
$ sudo apt-get install apache2 php7.0 php7.0-dev
Install dependencies
$ sudo apt-get install build-essential unzip libaio1 php-pear
Create a directory to install instant client
$ sudo -p mkdir /opt/oracle
Download Oracle Instant client from official website. You will have to register a free account to download the package. Select Instant Client for Linux x86-64, accept licence agreement and download following packages.
instantclient-basic-linux.x64-12.2.0.1.0.zip instantclient-sdk-linux.x64-12.2.0.1.0.zip
Unzip both downloaded packages into /opt/oracle
$ sudo unzip -o instantclient-basic-linux.x64-12.2.0.1.0.zip -d /opt/oracle $ sudo unzip -o instantclient-sdk-linux.x64-12.2.0.1.0.zip -d /opt/oracle
Create symbolic links as installation is done via .zip file
sudo ln -s /opt/oracle/instantclient/sqlplus /usr/bin/sqlplus sudo ln -s /opt/oracle/instantclient_12_2 /opt/oracle/instantclient sudo ln -s /opt/oracle/instantclient/libclntsh.so.12.2 /opt/oracle/instantclient/libclntsh.so sudo ln -s /opt/oracle/instantclient/libocci.so.12.2 /opt/oracle/instantclient/libocci.so
Now install oci8
$ sudo pecl install oci8
On the process of installation, when prompted, enter ‘instantclient,/opt/oracle/instantclient’
On completion of the installation, success message will be displayed and will ask to add ‘extension=oci8.so’ in php.ini of your PHP installation.
In my case it was /etc/php/7.0/cli/php.ini
Optionally, if you run into issue saying,
... libmql1.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
then do run this command from terminal.
LD_LIBRARY_PATH=/opt/oracle/instantclient:$LD_LIBRARY_PATH
And you are good to go.