can not load oci8 -> Fatal error: Call to undefined function oci_connect()

allrise picture allrise · Dec 10, 2015 · Viewed 27.3k times · Source

I want to connect to my oracle database, but i have a problem with function oci_connect. i have tried to uncomment this:

extension=php_oci8.dll 

but, still have an error :

Fatal error: Call to undefined function oci_connect() in C:\xampp\htdocs\testing\db.php on line 71

But, when i check in phpinfo(), oci8 still not loaded and i can not connect to my oracle database. i already restart my apache. How i fix this problem ? Canyou help me?

Thank you..

Answer

Rômulo Z. C. Cunha picture Rômulo Z. C. Cunha · Jul 5, 2017

In Ubuntu 16.04, using PHP 5.6, with 64bit os, try this:

Install the packages:

sudo apt-get install php5.6-dev build-essential php-pear libaio1

Download the latest version of the packages from:

http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

Search for these packages, according with the latest version:

oracle-instantclientXX.X-basic-XX.X.X.X.X-X.x86_64.rpm
oracle-instantclientXX.X-devel-XX.X.X.X.X-X.x86_64.rpm

Converting packages:

sudo apt-get install alien
sudo alien oracle-instantclientXX.X-basic-XX.X.X.X.X-X.x86_64.rpm
sudo alien oracle-instantclientXX.X-devel-XX.X.X.X.X-X.x86_64.rpm

Installing:

sudo dpkg -i oracle-instantclientXX.X-basic_XX.X.X.X.X-X_amd64.deb
sudo dpkg -i oracle-instantclientXX.X-devel_XX.X.X.X.X-X_amd64.deb

Installing oci8:

sudo pecl install oci8-2.0.12

*Build process completed successfully
Installing '/usr/lib/php/20131226/oci8.so'
install ok: channel://pecl.php.net/oci8-2.0.12
configuration option "php_ini" is not set to php.ini location
You should add "extension=oci8.so" to php.ini*

Add the extension to php:

sudo gedit /etc/php/5.6/apache2/php.ini

add the extension:

extension=oci8.so

Restart apache:

sudo service apache2 restart

That's it.