phpphp-7.2rhel6

php-oci8 - libclntsh.so.18.1: cannot open shared object file


In RHEL 6 I have installed PHP 7.2 via remi repository:

# yum --enablerepo=remi-php72 install php

Checked which modules are preinstalled with php -m. It is not listed. So I proceed to install it:

# yum --enablerepo=remi-php72 php72-php-oci8

Installed:
  php72-php-oci8.x86_64 0:7.2.17-1.el6.remi

Complete!

Check modules again and oci8 not yet loaded. In order to test if it fails with all modules I tried with mbstring (not installed by default):

# yum --enablerepo=remi-php72 install php-mbstring
Installed:
  php-mbstring.x86_64 0:7.2.17-1.el6.remi

Complete!

If I do php -m mbstring successfully listed there. Am I missing something with oci8? Thank you in advance.

Update

I have added the extension into php.ini file with extension=oci8. Then I did php -m:

PHP Warning: PHP Startup: Unable to load dynamic library 'oci8' (tried: /usr/lib64/php/modules/oci8 (/usr/lib64/php/modules/oci8: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/oci8.so (libclntsh.so.18.1: cannot open shared object file: No such file or directory)) in Unknown on line 0

Looks like php can not find libclntsh.so.18.1 library from Oracle client. So I decided to check the oracle's home lib to take look:

# ls -l libclntsh*
lrwxrwxrwx. 1 oracle oinstall       61 Mar 26 16:20 libclntsh.so -> /u01/app/oracle/product/11.2.0/dbhome_1/lib/libclntsh.so.11.1
lrwxrwxrwx. 1 oracle oinstall       56 Mar 26 16:19 libclntsh.so.10.1 -> /u01/app/oracle/product/11.2.0/dbhome_1/lib/libclntsh.so
-rwxr-xr-x. 1 oracle oinstall 47251283 Mar 26 16:20 libclntsh.so.11.1

What I am thinking is that the oci8 extension is trying to load this library for 18c oracle version while my current client is 11g. No idea on how to solve it.


Solution

  • To solve this problem, it is necessary to download Oracle Client 18.5.0 Base - Linux x86-64 here:

    https://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

    Unzip sources as oracle user:

    $ cd /u01/app/oracle/product/
    $ mkdir 18.5.0
    $ cd 18.5.0
    $ wget -c https://download.oracle.com/otn/linux/instantclient/185000/instantclient-basic-linux.x64-18.5.0.0.0dbru.zip?AuthParam=1555443721_28dfadc632483f950d87ee5f54810e06 -O instantclient-basic-linux.x64-18.5.0.0.0dbru.zip
    $ unzip instantclient-basic-linux.x64-18.5.0.0.0dbru.zip
    

    Doing ls you can confirm that the library is right there:

    $ ls -l instantclient_18_5/
    total 227712
    -rwxr-xr-x. 1 oracle oinstall     42360 Feb 26 20:04 adrci
    -r-xr-xr-x. 1 oracle oinstall      5780 Feb 26 20:04 BASIC_LICENSE
    -rw-r--r--. 1 oracle oinstall      1632 Feb 26 20:04 BASIC_README
    -rwxr-xr-x. 1 oracle oinstall     66672 Feb 26 20:04 genezi
    -rwxrwxr-x. 1 oracle oinstall   8357160 Feb 26 20:04 libclntshcore.so.18.1
    lrwxrwxrwx. 1 oracle oinstall        17 Apr 16 20:42 libclntsh.so -> libclntsh.so.18.1
    -rwxrwxr-x. 1 oracle oinstall  78200832 Feb 26 20:04 libclntsh.so.18.1
    -r-xr-xr-x. 1 oracle oinstall   3551217 Feb 26 20:04 libipc1.so
    -r-xr-xr-x. 1 oracle oinstall    467932 Feb 26 20:04 libmql1.so
    -r-xr-xr-x. 1 oracle oinstall   6636088 Feb 26 20:04 libnnz18.so
    lrwxrwxrwx. 1 oracle oinstall        15 Apr 16 20:42 libocci.so -> libocci.so.18.1
    -r-xr-xr-x. 1 oracle oinstall   2282891 Feb 26 20:04 libocci.so.18.1
    -rwxr-xr-x. 1 oracle oinstall 126959616 Feb 26 20:04 libociei.so
    -r-xr-xr-x. 1 oracle oinstall    160875 Feb 26 20:04 libocijdbc18.so
    -r-xr-xr-x. 1 oracle oinstall    394835 Feb 26 20:04 libons.so
    -r-xr-xr-x. 1 oracle oinstall    117635 Feb 26 20:04 liboramysql18.so
    drwxr-xr-x. 3 oracle oinstall      4096 Feb 26 20:04 network
    -r--r--r--. 1 oracle oinstall   4161744 Feb 26 20:04 ojdbc8.jar
    -r--r--r--. 1 oracle oinstall   1398331 Feb 26 20:04 ucp.jar
    -rwxr-xr-x. 1 oracle oinstall    242008 Feb 26 20:04 uidrvci
    -rw-r--r--. 1 oracle oinstall     74263 Feb 26 20:04 xstreams.jar
    

    Finnaly, it is mandatory to set LD_LIBRARY_PATH env variable in order to let PHP where to find the library:

    $ export LD_LIBRARY_PATH=/u01/app/oracle/product/18.5.0/instantclient_18_5
    

    Now, you can check that oci8 is correctly listed there:

    $ php -m
    [PHP Modules]
    bz2
    calendar
    Core
    ctype
    curl
    date
    exif
    fileinfo
    filter
    ftp
    gettext
    hash
    iconv
    json
    libxml
    mbstring
    oci8