2

I have gone through the whole process of downloading Oracle instant client, SDK, etc. in a Ubuntu Server 17.04. Then converted rpm packages to deb with alien, installed, set the paths, downloaded pecl oci8, compiled and installed (w/o errors), etc. and then added the line:

extension=/usr/lib/php/20151012/oci8.so

And restarted. When I check the /var/log/apache2/error.log I see:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/oci8.so' - libmql1.so: cannot open shared object file: No such file or directory in Unknown on line 0
[Thu Jul 20 10:46:44.352631 2017] [mpm_prefork:notice] [pid 23450] AH00163: Apache/2.4.25 (Ubuntu) configured -- resuming normal operations
[Thu Jul 20 10:46:44.352717 2017] [core:notice] [pid 23450] AH00094: Command line: '/usr/sbin/apache2'

Does any one know what I could do to make it work? I guess I have not selinux enabled or maybe it is a permissions problem?

Thanks

1
  • FYI I've added the extension=/usr/lib/php/20151012/oci8.so to the etc/php/7.0/cli/php.ini and then did php --ri oci8 and all worked great. I could even run from command line the .php connection test and worked great. storage5.static.itmages.com/i/17/0721/…
    – Enrique
    Jul 21, 2017 at 11:55

3 Answers 3

5

The solution is to put the ORACLE global variables NOT in /etc/environment but in the /etc/apache2/envvars

So, I've added these 2 lines at the end of /etc/apache2/envvars

export LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64/lib
export ORACLE_HOME=/usr/lib/oracle/12.2/client64

And all working great

3
  • 2
    the export of LD_LIBRARY_PATH was what I was missing apparently. Did that and the issue went away. Thanks +1 Sep 15, 2017 at 8:53
  • 1
    This should be marked as answer. For some reason on 16.04 this step wasn't needed. May 8, 2018 at 11:52
  • This is the right answer. Worked for me too. Aug 26, 2021 at 12:17
2

As you still will have the same problem with php cli with the above solution, it would be better to add a new file /etc/ld.so.conf.d/oracle.conf with this content:

/usr/lib/oracle/12.2/client64/lib

Then run

sudo ldconfig

This way it works for apache and php cli and you do not need to change /etc/apache2/envvars

2

With Linux Ubuntu 18, if you're getting the same message, but its command line version: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20170718/oci8' when using php cli (= command line, as opposed to php as an apache module), all you need to do is to set LD_LIBRARY_PATH (not ORACLE_HOME), inside of /etc/environment, as shown below:

export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2

Next time you open a shell, the environment will declare this variable.

Note that the variable value needs to point to the folder that contains the lib*.so files.

Verification: open a new console, and run php -m | grep oci8

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.