Search code examples
phporacle-databaseapacheoci8

Cannot connect to Oracle (oci8) with Apache (FPM). PHP 7.x CLI is OK


I made a PHP script that connect to Oracle (oci8 extension). It works well when i run it with CLI mode (# php test-oracle.php)

But the same script opened in the the browser (Apache + PHP 7.x FPM) do not works and i got this error:

oci_connect(): OCIEnvNlsCreate() failed. There is something wrong with your system - please check that LD_LIBRARY_PATH includes the directory with Oracle Instant Client libraries

I read and follow many things that i found in forums (also in stackoverflow) but nothing work for apache.

Ubuntu 16.04 LTS / Apache 2.4.33 / PHP 7.1.18

Thanks!


Solution

  • I found the solution and so answer to my self.

    My Oracle Instant Client version was little too old (11.2.x) and i updated to a new one (12.1.x) and follow a standard guide (see below) for my case. And now it's works with apache without nothing else.

    https://gist.github.com/hewerthomn/81eea2935051eb2500941a9309bca703

    So i guess was some permission problem or something like that with this library.

    Again thanks for your help!