Search code examples
phporacle-databaseredhatoci8

Installation of OCI8 : how to correct "Use of undefined constant OCI_COMMIT_ON_SUCCESS" error?


I'm trying to install OCI8 on a RedHat Server (RHEL7) for my Apache Server. At this moment, when I try to connect to my server with Symphony, I get this error:

Exception "ErrorException" : Use of undefined constant OCI_COMMIT_ON_SUCCESS - assumed 'OCI_COMMIT_ON_SUCCESS'

Here is what I did to install OCI8.

  1. Installation of oracle-instantclient11.2 RPMs (devel and basic).
  2. Installation of the OCI8 package :

For information, I already have an Oracle 12C on my server but I want to connect my PHP application to another server (Oracle 11GR2).

tar zxvf oci8-2.1.7.tgz
cd oci8-2.1.7
phpize
./configure --with-oci8=shared,instantclient,/usr/lib/oracle/11.2/client64/lib --with-php-config=/opt/rh/rh-php56/root/usr/bin/php-config 
make
make install
  1. Edit php.ini in order to add extension=oci8.so.

I found this thread and I tried to used oci_connect and I get this error:

Fatal error: Call to undefined function oci_connect()

How can I correct this problem?


EDIT: I just found this error in php_error.log:

[26-Sep-2017 16:14:12 Europe/Paris] PHP Warning: PHP Startup: Unable to load dynamic library '/opt/rh/rh-php56/root/usr/lib64/php/modules/oci8.so' - /opt/rh/rh-php56/root/usr/lib64/php/modules/oci8.so: undefined symbol: _emalloc_128 in Unknown on line 0


Solution

  • According to this thread, the PHP Warning is caused by a library clash. So, I totally uninstall OCI8 manually and install it again. But, this time, I didn't choose the last version because I read on PECL website:

    Use 'pecl install oci8-2.0.12' to install for PHP 5.2 - PHP 5.6.

    Also, because I already have an Oracle Database on my server, I used those commands in order to install the extension:

    tar zxvf oci8-2.0.12.tgz
    cd oci8-2.0.12
    phpize
    ./configure --with-oci8=shared,$ORACLE_HOME --with-php-config=/opt/rh/rh-php56/root/usr/bin/php-config 
    make
    make install
    

    Now, I can found OCI8 extension listed in my phpinfo page.