skip to Main Content

My server is centos7, I managed to setup apache,php7.1,oracle-instantclient18.3-basic and oci8 on it. OCI8 is working fine now when I run the code on CLI, it connects the db and fetches data, only with one warning (also appears on running php -v) :

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/pdo_oci.so' - /usr/lib64/php/modules/pdo_oci.so: undefined symbol: php_pdo_unregister_driver in Unknown on line 0

unlike when I open up the page via browser (on a client machine) I got this error:

Fatal error: Uncaught Error: Call to undefined function oci_connect() in /var/www/html/pcmapi/emp.php:5 Stack trace: #0 {main} thrown in /var/www/html/pcmapi/emp.php on line 5

phpinfo() returns:

oci8
OCI8 Support => enabled
OCI8 DTrace Support => enabled
OCI8 Version => 2.1.8
Oracle Run-time Client Library Version => 18.3.0.0.0
Oracle Compile-time Instant Client Version => 18.3

Directive => Local Value => Master Value
oci8.connection_class => no value => no value
oci8.default_prefetch => 100 => 100
oci8.events => Off => Off
oci8.max_persistent => -1 => -1
oci8.old_oci_close_semantics => Off => Off
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20

I cannot actually recognize what causes the fatal error whether in apache or oci configuration and I find it strange that oci functions are working fine on cli but not apache. any help?

3

Answers


  1. Chosen as BEST ANSWER

    Thanks for your time, I actually did reinstall all the environment over again, this was painful as its a production server but paid back.. while I had mysql & instantclient already setup, I removed php & httpd then reinstall them all as the following:

    yum install httpd php php-mysql php-devel php-oci8 php-pear mod_ssl
    

    and then:

    service httpd restart
    

    now it works.


  2. The solution is to make sure you are loading pdo.so before you load pdo_oci.so.

    I do not know the exact configuration you are using, but on Ubuntu for example, I have the pdo_mysql.so loading after pdo.so by having these configuration files in the PHP’s conf.d:

    10-pdo.ini:

    extension=pdo.so
    

    20-pdo-mysql.ini:

    extension=pdo_mysql.so
    

    Notice that the file 10-pdo.ini will load earlier than 20-pdo-mysql.ini simply because of its file name.

    Good luck.

    Login or Signup to reply.
  3. The common issue is that Apache doesn’t have the Oracle client libraries (e.g. Instant Client) in its library search path. The reason PHP works in command line is because your shell does have the library search path correctly set.

    If you don’t have other Oracle libraries on this computer then do:

      sudo sh -c "echo /usr/lib/oracle/18.3/client64/lib > /etc/ld.so.conf.d/oracle-instantclient.conf"
      sudo ldconfig
    

    If you do have other software that would conflict, then do something like edit /etc/sysconfig/httpd and add:

    LD_LIBRARY_PATH=/usr/lib/oracle/18.3/client64/lib
    

    Depending on your Apache version, how you set the environment varies (yay!)

    You may or may not need to export this:

    export LD_LIBRARY_PATH=/usr/lib/oracle/18.3/client64/lib
    

    On other systems you can use Apaches envvars file.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search