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
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:
and then:
now it works.
The solution is to make sure you are loading
pdo.so
before you loadpdo_oci.so
.I do not know the exact configuration you are using, but on Ubuntu for example, I have the
pdo_mysql.so
loading afterpdo.so
by having these configuration files in the PHP’sconf.d
:10-pdo.ini:
20-pdo-mysql.ini:
Notice that the file
10-pdo.ini
will load earlier than20-pdo-mysql.ini
simply because of its file name.Good luck.
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:
If you do have other software that would conflict, then do something like edit
/etc/sysconfig/httpd
and add:Depending on your Apache version, how you set the environment varies (yay!)
You may or may not need to export this:
On other systems you can use Apaches envvars file.