2

I am running a Ubuntu-nginx-php7-fpm machine and phpinfo() does not detect the oracle extension.

How can i tell to nginx or php that the oracle-php extension is installed?

The machine is a clone from another where oracle php7-fpm works.

When running phpinfo() from php oracle is not listed and even oci-connect does dot works or is listed at the error.log

Ângelo Rigo
  • 123
  • 1
  • 8
  • If `phpinfo` doesn't show the extension it's *not* installed. – ceejayoz Dec 18 '15 at 13:38
  • yes i know ! i meant much more about how to discover where instantclient oracle is installed, and how to make php7-fpm to detect oracle or install php7-oracle extension – Ângelo Rigo Dec 18 '15 at 13:54
  • To my knowledge, PHP 7 isn't available in Ubuntu's repositories yet, so you'll have to ask whoever provided your packages. – ceejayoz Dec 18 '15 at 13:55
  • Oracle is not on /etc/php/mods-available only : json.ini mysqli.ini opcache.ini pdo_mysql.ini wich action can install oracle module – Ângelo Rigo Dec 18 '15 at 17:20

1 Answers1

2

I cannot provide what is missing in your case. Here are all the steps to enable oci 8 for php-fpm.

First install oci8.so using steps bellow:

Install PECL, PHP Development files, Build Essential, Unzip, and the AIO Library

apt-get install php-pear php7.0-dev build-essential unzip libaio1

Create the oracle directory

mkdir /opt/oracle

Download instant client from this link. Download 11.2 Basic & SDK. Only 11.2 version was working for me.

Move the downloaded files

mv instantclient-* /opt/oracle

Unzip the files using the unzip command (unzip ) Rename the created directory

mv instantclient_11_2 instantclient

cd into the instant client directory and create the following soft links

ln -s libclntsh.so.11.2 libclntsh.so
ln -s libocci.so.11.2 libocci.so

cd to  /opt

set the permissions on the directory

chown -R root:www-data /opt/oracle

Add the instant client to the the ld config files

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

Update the Dynamic Linker Run-Time Bindings

ldconfig

Install OCI8 using PECL

pecl install oci8

When you are pompted for the client location enter the following:

instantclient,/opt/oracle/instantclient

Lastly configure php.ini

At this moment your oci8.so is ready to be use. Just include into your php.ini file.

cd /etc/php/mods-available/
vi oci.ini

then add this line to the file "extension=oci8.so"

Now create a symlink like this:

cd /etc/php/7.0/fpm/config.d/
ln -s /etc/php/mods-available/oci.ini 20-oci.ini

Add oracle enviroment variables:

vi /etc/environment

Add the following lines:

# Oracle Instant Client
export LD_LIBRARY_PATH="/opt/oracle/instantclient"
export TNS_ADMIN="/opt/oracle/instantclient"
export ORACLE_BASE="/opt/oracle/instantclient"
export ORACLE_HOME=$ORACLE_BASE

Finally restart fpm service:

sudo php7.0-fpm restart

You must be able to check oci8 extension through phpinfo.