PHP with Oracle

I am personally working on a Project, that has web UI having Apache server, PHP on server side and Oracle as database. For this I need to configure PHP so that it can talk to my Oracle database. The first error I got while querying the database using PHP was.
Call to undefined function oci_connect()
For this, we need to first install php5-pear and then using pecl, we need to install OCI8. As I am using openSUSE 13.2
sudo zypper in php5-pear
Then install OCI8 extension for PHP
sudo pecl install oci8
This will install and compile oci8 module. This command will ask for ORACLE HOME location. If everything goes fine, this will end like
Build process completed successfully
Installing '/usr/lib64/php5/extensions/'
install ok: channel://
configuration option "php_ini" is not set to php.ini location
You should add "" to php.ini
Add the line
to your /etc/php/apache2/php.ini and /etc/php/cli/php.ini Then restart Apache server
sudo systemctl restart apache2.service
After this when I tried to access Oracle, I got the error “Call to undefined function oci_connect()” again! When I checked in /var/log/apache2/err_log, I found this:
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php5/extensions/' - cannot open shared object file: No such file or directory in Unknown on line 0
So even though the file is present at $ORACLE_HOME/lib, I still get this error. To get over this error, we need two more steps. Create a file /etc/ and add this line it:
and run “ldconfig”. Restart your Apache server again, and this time things should work!

Leave a Comment

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.