0

I am trying to set up Laravel 5.6 + PHP 7.2 (with Instantclient 12.2 and oracle OCI) + Nginx on Ubuntu 18.2. Also, I have installed "yajra/laravel-oci8": "^5.6" for Laravel. To make sure I have instantclient installed correctly, I also tried sqlplus to make sure I can establish connection with the oracle server.

So, I should have everything configured properly and the oracle connector works fine when I serve the page with "php artisan serve --host=192.168.56.12 --port=8000" command.

The test code is as follows:

public function testorcl(){
    if (function_exists('oci_connect') == false){
        return "oci driver not available";
    }
}

At same time, I have Nginx enabled on the default port 80. Both web server are serving the same Laravel code base.

Strangely, Nginx can not find the oci_connect()!!

Then, I check phpinfo() page on both servers.

enter image description here

I found out that the oci8 module is not mounted on Nginx server. But, the "php artisan serve" shows oci8 is mounted. The oci8 module mounted should display something like the following image. enter image description here

Not only the oci8 module part is different, the environment variables lists are also different. Nginx gives only 4 environment variables shown below while php artisan provides a long list of variables (which is too long to be displayed here in a single page). enter image description here

So, I think it's the Nginx that causes the problem. Here is my Nginx configuration.

server {
         listen 80;
         listen [::]:80 ipv6only=on;

         # Log files for Debugging
         access_log /var/log/nginx/laravel-access.log;
         error_log /var/log/nginx/laravel-error.log;

         # Webroot Directory for Laravel project
         root /home/ub18/test/public;
         index index.php index.html index.htm;

         # Your Domain Name
         #server_name example.com;

         location / {
                 try_files $uri $uri/ /index.php?$query_string;
         }

         # PHP-FPM Configuration Nginx
         location ~ \.php$ {
                 try_files $uri =404;
                 fastcgi_split_path_info ^(.+\.php)(/.+)$;
                 fastcgi_pass unix:/run/php/php7.2-fpm.sock;
                 fastcgi_index index.php;
                 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
         fastcgi_param SCRIPT_NAME $fastcgi_script_name;
                 include fastcgi_params;
         }

    # deny access to . files, for security
    #
    location ~ /\. {
        log_not_found off; 
        deny all;
    }
 }

The questions are: 1. How to make my OCI work? What did I miss out? 2. How I can make sure Nginx can load the correct environment variables just like "php artisan serve"?

Any suggestions are welcomed, thanks.

Dean Chiu
  • 1,325
  • 1
  • 13
  • 13
  • Did you ever get to the bottom of this? I wasn't able to get `oci_connect()` to work. My only out at the moment is to uninstall Nginx and try Apache instead!! – cartbeforehorse Oct 25 '18 at 22:59
  • I just noticed that your `LD_LIBRARY_PATH` should be pointing to `$ORACLE_HOME/bin`, and not to the same location as Oracle Home. This *could* be a (but might not be a full) solution to your problem. – cartbeforehorse Oct 27 '18 at 09:12

0 Answers0