PHP 7.0 Apache Oracle 12 Instantclient OCI8 install apt-get

If you need to do this from scratch I have followed these how-to-install-and-configure-php-70-or-php-71-on-ubuntu-16-04 insructions to install PHP7.0 and apache.

Once installed then
Follow these instructions to compile oci8 extentions Oracle tech note OCI8

Download the instant client from oracle’s web site here : Oracle instant client download
I downloaded the .ZIP files since I dont have RPM installed.
I then extracted it to ~/Downloads/instantclient_12_2
NOTE: Download the and

cd ~Downloads

Now we need to create the paths

sudo mkdir /usr/lib/oracle
sudo mkdir /usr/lib/oracle/12.2
sudo mkdir /usr/lib/oracle/12.2/client64
sudo mkdir /usr/lib/oracle/12.2/client64/lib
cd ~/Downloads/instantclient_12_2
sudo cp * /usr/lib/oracle/12.2/client64/lib/
cd /usr/lib/oracle/12.2/client64/lib/
ln -s
sudo mkdir /usr/include/oracle
sudo mkdir /usr/include/oracle/12.2
sudo mkdir /usr/include/oracle/12.2/client64
cd ~/Downloads/instantclient_12_2/sdk/include
sudo cp * /usr/include/oracle/12.2/client64
export ORACLE_HOME=/usr/lib/oracle/12.2

Edit and include oracle libs. Add a file called oracle.conf under /etc/

cd /etc/
sudo vi oracle.conf

Now to download and compile OCI8

sudo pecl install oci8 --with-oci8=instantclient,/usr/lib/oracle/12.2/client64/lib

On My machine it compiled it under ‘/usr/lib/php/20151012/’ but look at the last few lines it should echo it.

First lets install a page to test that the configuration works.

sudo vi /var/www/html/t.php ( or xed /var/www/html/t.php if you dont know vi)
Press ESC i and paste

Press ESC :qw

now open your favorite browser and go to http://localhost/t.php and you should see a information page of php

to configure php do:

cd /etc/php/7.0/mods-available
vi oci8.ini

Edit oci8.ini with content

Now restart

sudo service apache2 restart

My Installation now gave an error

apachectl configtest
if you get an error about cannot open shared object file: No such file or directory

sudo apt-get install libaio1 libaio-dev

Now we need to give the path to the libraries.
Edit /etc/apache2/envvars and add the flowing to the bottom of the file


To Test

php --ri oci8

Leave a Reply

Your email address will not be published.

Reload Image