Topic: PHP Startup: Unable to load dynamic library libclntsh.so.12.1

hi,

I have installed oracle packages:

oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64
oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64
oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64

All Oracle Library are located at "/usr/lib/oracle/12.1/client64/lib/"

I have installed php5.6.19 and also related php-oci & pdo packages on CentOS Linux release 7.2.1511 (Core)

I'm unable to connect to OracleDB even though I installed all required packages. I'm getting following error, when the libraries are present in the system.

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

I even followed the steps given in oracle community forum and configured the runtime env variable for oracle for Apache config file "/etc/sysconfig/httpd"

ORACLE_HOME=/usr/lib/oracle/12.1/client64
LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib
LD_LIBRARY_PATH64=/usr/lib/oracle/12.1/client64/lib


Please let me know what I'm missing here??

Appreciated your help.

Re: PHP Startup: Unable to load dynamic library libclntsh.so.12.1

Distro ? Version ? Arch ?

WIth EL-6 you need to "export LD_LIBRARY_PATH=..." in /etc/sysconfig/httpd
With EL-7 and Fedora, only "LD_LIBRARY_PATH=..."

Where do you see this error message ?
In apache log ? or in CLI ?

For cli, of course, you also need to set LD_LIBRARY_PATH (using export)

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

3 (edited by skonealone 2016-04-18 17:07:38)

Re: PHP Startup: Unable to load dynamic library libclntsh.so.12.1

hi,

CentOS 7.2 64bit

I get error in both, in cli as well as in apache error log :-(

$ php -v
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/oci8.so' - libclntsh.so.12.1: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/pdo_oci.so' - libclntsh.so.12.1: cannot open shared object file: No such file or directory in Unknown on line 0
PHP 5.6.19 (cli) (built: Mar  3 2016 07:57:20)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Suhosin v0.9.38, Copyright (c) 2007-2015, by SektionEins GmbH



I did added export in /etc/sysconfig/httpd:

export LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib
export LD_LIBRARY_PATH64=/usr/lib/oracle/12.1/client64/lib

After adding above export I still get error in apache error_log :-(

For cli I dont know which file i have to add the export.

appreciate your help.

Re: PHP Startup: Unable to load dynamic library libclntsh.so.12.1

With CentOS 7 you don't need the "export" word in  /etc/sysconfig/httpd:

$ ls -al /usr/lib/oracle/12.1/client64/lib
$ LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib  php -v

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

5 (edited by skonealone 2016-04-18 18:00:17)

Re: PHP Startup: Unable to load dynamic library libclntsh.so.12.1

I removed the export word in /etc/sysconfig/httpd
I followed the steps you mentioned but still I get the same error :-(

# export LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib
# php -v
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/oci8.so' - libclntsh.so.12.1: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/pdo_oci.so' - libclntsh.so.12.1: cannot open shared object file: No such file or directory in Unknown on line 0
PHP 5.6.19 (cli) (built: Mar  3 2016 07:57:20)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Suhosin v0.9.38, Copyright (c) 2007-2015, by SektionEins GmbH

Re: PHP Startup: Unable to load dynamic library libclntsh.so.12.1

Please, output of above commands

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: PHP Startup: Unable to load dynamic library libclntsh.so.12.1

now I'm getting followin error, after manually export the LD_PATH & removed the "export" word from "/etc/sysconfig/httpd"

PHP Fatal error:  Uncaught exception 'PDOException' with message 'No support for Oracle, please install the OCI driver' in /var/www-data/blox-net/app/libraries/pdooci/PDO.php:49

Re: PHP Startup: Unable to load dynamic library libclntsh.so.12.1

Still don't want to answer my questions....

Going to sleep.

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: PHP Startup: Unable to load dynamic library libclntsh.so.12.1

sorry bro.. I did sent you output of commands, here again I'm sending output of commands:

]#  ls -al /usr/lib/oracle/12.1/client64/lib
total 193248
drwxr-xr-x. 2 root root      4096 Feb 23 11:45 .
drwxr-xr-x. 4 root root        26 Feb 23 11:45 ..
-rw-r--r--. 1 root root       342 Jul  7  2014 glogin.sql
lrwxrwxrwx. 1 root root        21 Feb 23 11:45 libclntshcore.so -> libclntshcore.so.12.1
-rw-r--r--. 1 root root   6990875 Jul  7  2014 libclntshcore.so.12.1
lrwxrwxrwx. 1 root root        17 Feb 23 11:45 libclntsh.so -> libclntsh.so.12.1
-rw-r--r--. 1 root root  58793741 Jul  7  2014 libclntsh.so.12.1
-rw-r--r--. 1 root root   1768370 Jul  7  2014 libipc1.so
-rw-r--r--. 1 root root    544150 Jul  7  2014 libmql1.so
-rw-r--r--. 1 root root   6213011 Jul  7  2014 libnnz12.so
lrwxrwxrwx. 1 root root        15 Feb 23 11:45 libocci.so -> libocci.so.12.1
-rw-r--r--. 1 root root   2576030 Jul  7  2014 libocci.so.12.1
-rw-r--r--. 1 root root 109549133 Jul  7  2014 libociei.so
-rw-r--r--. 1 root root    156353 Jul  7  2014 libocijdbc12.so
-rw-r--r--. 1 root root    337137 Jul  7  2014 libons.so
-rw-r--r--. 1 root root    118491 Jul  7  2014 liboramysql12.so
-rw-r--r--. 1 root root   1564082 Jul  7  2014 libsqlplusic.so
-rw-r--r--. 1 root root   1546540 Jul  7  2014 libsqlplus.so
-rw-r--r--. 1 root root   3670975 Jul  7  2014 ojdbc6.jar
-rw-r--r--. 1 root root   3677511 Jul  7  2014 ojdbc7.jar
-rw-r--r--. 1 root root    311555 Jul  7  2014 ottclasses.zip
-rw-r--r--. 1 root root     35925 Jul  7  2014 xstreams.jar


# export  LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib
[root@s-web01 ~]# php -v
PHP 5.6.19 (cli) (built: Mar  3 2016 07:57:20)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Suhosin v0.9.38, Copyright (c) 2007-2015, by SektionEins GmbH

Re: PHP Startup: Unable to load dynamic library libclntsh.so.12.1

ok, so everything look good.

No :

$ rpm -qa php\* | sort
$ php -m

And also display the connection string used.

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

11 (edited by crest 2016-05-27 12:33:21)

Re: PHP Startup: Unable to load dynamic library libclntsh.so.12.1

Hi Remi,

first of all, thank you for the great work you did with the php70 software collections. It makes the migration to php7 much easier.

Unfortunately, I’ve got the same Problem which skonealone had before in my CentOS release 6.6 x86_64 systems. It would be great if you can have a look on this issue.

Some slightly differences:
Using Oralce Instaclient 11.2
Using Centos 6.6
Using php 70 and modules as software collections from remi-safe.

I also get the following warnings:

PHP Warning:  PHP Startup: Unable to load dynamic library '/opt/remi/php70/root/usr/lib64/php/modules/oci8.so' - libclntsh.so.12.1: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/opt/remi/php70/root/usr/lib64/php/modules/pdo_oci.so' - libclntsh.so.12.1: cannot open shared object file: No such file or directory in Unknown on line 0

And as before Problem appears in cli and apache startup.

Here are some additional Information:

>cat /etc/sysconfig/httpd 
export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib
export LD_LIBRARY_PATH64=/usr/lib/oracle/11.2/client64/lib
>ll /usr/lib/oracle/11.2/client64/lib -la
total 181804
drwxr-xr-x 2 root root      4096 Aug 25  2014 .
drwxr-xr-x 4 root root      4096 Aug 25  2014 ..
-rw-r--r-- 1 root root  52761218 Sep 17  2011 libclntsh.so.11.1
-rw-r--r-- 1 root root   7955322 Sep 17  2011 libnnz11.so
-rw-r--r-- 1 root root   1971762 Sep 17  2011 libocci.so.11.1
-rw-r--r-- 1 root root 118408281 Sep 17  2011 libociei.so
-rw-r--r-- 1 root root    164836 Sep 17  2011 libocijdbc11.so
-rw-r--r-- 1 root root   2095661 Sep 17  2011 ojdbc5.jar
-rw-r--r-- 1 root root   2714016 Sep 17  2011 ojdbc6.jar
-rw-r--r-- 1 root root     66779 Sep 17  2011 xstreams.jar
>rpm -qa | grep php70
php70-php-7.0.6-3.el6.remi.x86_64
php70-php-oci8-7.0.6-3.el6.remi.x86_64
php70-php-common-7.0.6-3.el6.remi.x86_64
php70-php-fpm-7.0.6-3.el6.remi.x86_64
php70-php-odbc-7.0.6-3.el6.remi.x86_64
php70-php-pear-1.10.1-4.el6.remi.noarch
php70-php-json-7.0.6-3.el6.remi.x86_64
php70-php-pdo-7.0.6-3.el6.remi.x86_64
php70-php-xml-7.0.6-3.el6.remi.x86_64
php70-php-cli-7.0.6-3.el6.remi.x86_64
php70-php-ldap-7.0.6-3.el6.remi.x86_64
php70-php-process-7.0.6-3.el6.remi.x86_64
php70-runtime-1.0-4.el6.remi.x86_64
php70-1.0-4.el6.remi.x86_64
>rpm -qa | grep oracle
oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64
>scl enable php70 'export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib; php -v'
PHP Warning:  PHP Startup: Unable to load dynamic library '/opt/remi/php70/root/usr/lib64/php/modules/oci8.so' - libclntsh.so.12.1: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/opt/remi/php70/root/usr/lib64/php/modules/pdo_oci.so' - libclntsh.so.12.1: cannot open shared object file: No such file or directory in Unknown on line 0
PHP 7.0.6 (cli) (built: Apr 28 2016 21:34:10) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
>scl enable php70 'export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib; php -m'
PHP Warning:  PHP Startup: Unable to load dynamic library '/opt/remi/php70/root/usr/lib64/php/modules/oci8.so' - libclntsh.so.12.1: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/opt/remi/php70/root/usr/lib64/php/modules/pdo_oci.so' - libclntsh.so.12.1: cannot open shared object file: No such file or directory in Unknown on line 0
[PHP Modules]
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gettext
hash
iconv
json
ldap
libxml
odbc
openssl
pcntl
pcre
PDO
PDO_ODBC
pdo_sqlite
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
zlib

[Zend Modules]

Thanks in advance,
Crest

Re: PHP Startup: Unable to load dynamic library libclntsh.so.12.1

You have oracle client 11.1 while expected version (used for the build) is 12.1 (libclntsh.so.12.1 != libclntsh.so.11.1)

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: PHP Startup: Unable to load dynamic library libclntsh.so.12.1

Damn. Seems like i had badly misread the error message -.- Thanks for the fast Response.

Re: PHP Startup: Unable to load dynamic library libclntsh.so.12.1

I'm suffering the same issue. Details are:

Centos 7, PHP56, all steps followed in previous posts.

cat /etc/sysconfig/httpd
#
# etc.... etc....
#
LANG=C
LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib


ls -al /usr/lib/oracle/12.1/client64/lib
total 189896
drwxr-xr-x. 2 root root      4096 Nov 16 08:32 .
drwxr-xr-x. 4 root root        26 Nov 16 08:32 ..
-rw-r--r--. 1 root root   6990875 Jul  7  2014 libclntshcore.so.12.1
-rw-r--r--. 1 root root  58793741 Jul  7  2014 libclntsh.so.12.1
-rw-r--r--. 1 root root   1768370 Jul  7  2014 libipc1.so
-rw-r--r--. 1 root root    544150 Jul  7  2014 libmql1.so
-rw-r--r--. 1 root root   6213011 Jul  7  2014 libnnz12.so
-rw-r--r--. 1 root root   2576030 Jul  7  2014 libocci.so.12.1
-rw-r--r--. 1 root root 109549133 Jul  7  2014 libociei.so
-rw-r--r--. 1 root root    156353 Jul  7  2014 libocijdbc12.so
-rw-r--r--. 1 root root    337137 Jul  7  2014 libons.so
-rw-r--r--. 1 root root    118491 Jul  7  2014 liboramysql12.so
-rw-r--r--. 1 root root   3670975 Jul  7  2014 ojdbc6.jar
-rw-r--r--. 1 root root   3677511 Jul  7  2014 ojdbc7.jar
-rw-r--r--. 1 root root     35925 Jul  7  2014 xstreams.jar

Yet every time I start php56-php-fpm I get:

Nov 16 15:49:55 pja-test php-fpm: [16-Nov-2016 15:49:55] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library '/opt/remi/php70/root/usr/lib64/php/modules/oci8.so' - libclntsh.so.12.1: cannot open shared object file: No such file or directory in Unknown on line 0
Nov 16 15:49:55 pja-test php-fpm: [16-Nov-2016 15:49:55] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library '/opt/remi/php70/root/usr/lib64/php/modules/pdo_oci.so' - libclntsh.so.12.1: cannot open shared object file: No such file or directory in Unknown on line 0

Any help you can provide will be very much appreciated.

Re: PHP Startup: Unable to load dynamic library libclntsh.so.12.1

Of course....  /etc/sysconfig/httpd is for httpd service... not for php-fpm

See /opt/remi/php56/root/etc/sysconfig/php-fpm
Or better, use systemd feature (systemctl edit php56-php-fpm) to add an Environment=... directive.

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: PHP Startup: Unable to load dynamic library libclntsh.so.12.1

Thank you Remi - worked perfectly and, like I thought it might be, the answer was incredibly simple.

Re: PHP Startup: Unable to load dynamic library libclntsh.so.12.1

I have the same problem, I use php-fpm and fedora 24 and oracle client 12.

With ls I see the libclntshcore.so.12.1.

I not understnd you last answer "Of course....  not for php-fpm".

Where I to put the
LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client/lib

Re: PHP Startup: Unable to load dynamic library libclntsh.so.12.1

/etc/sysconfig/httpd is for httpd service
/etc/sysconfig/php-fpm is for fpm service

But with system, perhaps simpler to override the unit file with "systemctl edit php-fpm.service"
And add

       [Service]
       Environment=LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client/lib

(not tested)

Or even simpler, global way (for all processes)

echo "/usr/lib/oracle/12.1/client64/lib" > /etc/ld.so.conf.d/oracleclient.conf
Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: PHP Startup: Unable to load dynamic library libclntsh.so.12.1

Hello again. On a server using mod_php (don't ask) I have everything working fine. The only issue is an error warning. As root I can 'php -v' and get clean output. As a non-root user it I input 'php -v' I get the following:

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

Just curious as to what could be causing that as it has a couple of developers scared.

Re: PHP Startup: Unable to load dynamic library libclntsh.so.12.1

Answer is in above posts. Missing LD_LIBRARY_PATH to oracle client library.

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: PHP Startup: Unable to load dynamic library libclntsh.so.12.1

That's set in sysconfig/httpd and working correctly. I'm wondering why different users see different things.

I'll try the systemctl method you mentioned.

Re: PHP Startup: Unable to load dynamic library libclntsh.so.12.1

> That's set in sysconfig/httpd and working correctly.

This is for apache

> I'm wondering why different users see different things.

Because different user have different environment.

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: PHP Startup: Unable to load dynamic library libclntsh.so.12.1

I’ve got the same Problem which skonealone had before in my CentOS release 6.6 x86_64 systems. It would be great if you can have a look on this issue.

Re: PHP Startup: Unable to load dynamic library libclntsh.so.12.1

Thank you Remi - worked perfectly!