doutiaoku4495 2019-04-16 17:49
浏览 293

php-oci8 - libclntsh.so.18.1:无法打开共享对象文件

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.

  • 写回答

1条回答 默认 最新

  • dqoys62082 2019-04-16 19:58
    关注

    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
    
    评论

报告相同问题?

悬赏问题

  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题