Issue
pdo_oci or oci8 extensions not loading correctly with the following error:
PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_oci.so' (tried: /opt/alt/php**/usr/lib64/php/modules/pdo_oci.so (libclntsh.so.12.1: cannot open shared object file: No such file or directory), /opt/alt/php**/usr/lib64/php/modules/pdo_oci.so.so (/opt/alt/php**/usr/lib64/php/modules/pdo_oci.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Environment
- PHP Selector
- alt-php
Solution
- Download the Oracle Instant Client package from https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html
Please note that you do not need the latest version like 21.1 or any other.
Download the version requested: 12.1. - Install the package that provides missing libclntsh.so.12.1 library with the following command. You can find the repository in the following URLs: https://yum.oracle.com/ || https://yum.oracle.com/repo/OracleLinux/OL8/oracle/instantclient21/x86_64/index.html
# rpm -ihv link_to_package_oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
3. Add the ldd library:
Be careful! You need to use the path obtained with the find command in the following commands.
# find / -name libclntsh.so.12.1 2>/dev/null
/usr/lib/oracle/21/client64/lib/libclntsh.so.12.1
# export LD_LIBRARY_PATH=/usr/lib/oracle/21/client64/lib:/usr/lib/oracle/21/client64/lib/libclntsh.so.12.1
# echo "/usr/lib/oracle/21/client64/lib" > /etc/ld.so.conf.d/oracle-instantclient.conf
# ldconfig
--
In some other cases, it helps to remove the oracle-instantclient12.1-basic that came from cloudlinux-imunify360/cloudlinux-x86_64-server-7 and download version 21, install it, and link 12.1 to the 21 folder :
mkdir /root/paco; cd /root/paco/
wget https://yum.oracle.com/repo/OracleLinux/OL7/oracle/instantclient21/x86_64/getPackage/oracle-instantclient-basic-21.1.0.0.0-1.x86_64.rpm; wget https://yum.oracle.com/repo/OracleLinux/OL7/oracle/instantclient21/x86_64/getPackage/oracle-instantclient-devel-21.1.0.0.0-1.x86_64.rpm
yum remove oracle-instantclient12.1-basic
yum install oracle-instantclient-basic-21.1.0.0.0-1.x86_64.rpm oracle-instantclient-devel-21.1.0.0.0-1.x86_64.rpm
cd /usr/lib/oracle/12.1/client64/lib/
ln -s /usr/lib/oracle/21/client64/lib/libclntsh.so.12.1 .
Then you can try to test pdo_oci module for all PHP versions, and it will be loaded correctly:
for i in 52 53 54 55 56 70 71 72 73 74 80 81 82 ; do echo -n "PHP $i : " ; /opt/cpanel/ea-php${i}/root/usr/bin/php -dextension=pdo_oci.so -i | grep -i -E "^PDO drivers" ; done
Cause
The Oracle Instant Client package that provides libclntsh.so.12.1 missing and has to be downloaded separately
Comments
0 comments
Please sign in to leave a comment.