PHP7.0-FPM with Docker : Unable to load dynamic library OCI8

丶灬走出姿态 提交于 2019-12-25 00:39:21

问题


I have created a Docker Image with PHP7.0-FPM and Apache 2.4. I have installed InstantClient 12.2 (basic + sdk) and I have installed oci8 like this :

RUN echo "instantclient,/usr/lib/oracle/12.2/instantclient"| pecl install oci8 && \ echo "extension=oci8.so" > /etc/php/7.0/mods-available/oci8.ini && \ ln -s /etc/php/7.0/mods-available/oci8.ini /etc/php/7.0/fpm/conf.d/20-oci8.ini

I don't know why, but I am getting this warning when I (re)start php7.0-fpm :

# service php7.0-fpm restart * Restarting PHP 7.0 FastCGI Process Manager php-fpm7.0 Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/oci8.so' - libmql1.so: cannot open shared object file: No such file or directory in Unknown on line 0

Locations of oci8.so and libmql1.so seems to be ok :

# ll /usr/lib/oracle/12.2/instantclient/
total 216700
drwxrwxrwx 3 root www-data      4096 Dec 11 15:12 ./
drwxr-xr-x 4 root www-data      4096 Dec 12 08:24 ../
-rwxrwxrwx 1 root www-data       363 Jan 26  2017 BASIC_README*
-rwxrwxrwx 1 root www-data     44220 Jan 26  2017 adrci*
-rwxrwxrwx 1 root www-data     57272 Jan 26  2017 genezi*
lrwxrwxrwx 1 root www-data        52 Dec 11 15:02 libclntsh.so -> /usr/lib/oracl
e/12.2/instantclient/libclntsh.so.12.1*
-rwxrwxrwx 1 root www-data  71638263 Jan 26  2017 libclntsh.so.12.1*
-rwxrwxrwx 1 root www-data   8033199 Jan 26  2017 libclntshcore.so.12.1*
-rwxrwxrwx 1 root www-data   2981501 Jan 26  2017 libipc1.so*
-rwxrwxrwx 1 root www-data    539065 Jan 26  2017 libmql1.so*
-rwxrwxrwx 1 root www-data   6568149 Jan 26  2017 libnnz12.so*
lrwxrwxrwx 1 root root            50 Dec 11 15:12 libocci.so -> /usr/lib/oracle/
12.2/instantclient/libocci.so.12.1*
-rwxrwxrwx 1 root www-data   2218687 Jan 26  2017 libocci.so.12.1*
-rwxrwxrwx 1 root www-data 124771800 Jan 26  2017 libociei.so*
-rwxrwxrwx 1 root www-data    158543 Jan 26  2017 libocijdbc12.so*
-rwxrwxrwx 1 root www-data    380996 Jan 26  2017 libons.so*
-rwxrwxrwx 1 root www-data    116563 Jan 26  2017 liboramysql12.so*
-rwxrwxrwx 1 root www-data   4036257 Jan 26  2017 ojdbc8.jar*
drwxrwxrwx 5 root www-data      4096 Jan 26  2017 sdk/
-rwxrwxrwx 1 root www-data    240476 Jan 26  2017 uidrvci*
-rwxrwxrwx 1 root www-data     74230 Jan 26  2017 xstreams.jar*

I have added to /etc/php/7.0/fpm/pool.d/www.conf these 4 lines :

env[LD_LIBRARY_PATH] = /usr/lib/oracle/12.2/instantclient env[TNS_ADMIN] = /etc/oracle env[ORACLE_BASE] = /usr/lib/oracle/12.2/instantclient env[ORACLE_HOME] = /usr/lib/oracle/12.2/instantclient

Would I've missed something?

Thanks


回答1:


It's ok ! I was missing a .conf in /etc/ld.so.conf.d/oracle-instantclient.conf

RUN echo "instantclient,/usr/lib/oracle/12.2/instantclient"| pecl install oci8 && \
echo "extension=oci8.so" > /etc/php/7.0/mods-available/oci8.ini && \
ln -s /etc/php/7.0/mods-available/oci8.ini /etc/php/7.0/fpm/conf.d/20-oci8.ini && \
echo /usr/lib/oracle/12.2/instantclient > /etc/ld.so.conf.d/oracle-instantclient.conf && \
ldconfig



回答2:


Try adding those env variable in /etc/apache2/envvars add at end of the file, like

  • export LD_LIBRARY_PATH=/usr/lib/oracle/12.2/instantclient

  • export TNS_ADMIN=/etc/oracle

  • export ORACLE_BASE=/usr/lib/oracle/12.2/instantclient

  • export ORACLE_HOME=/usr/lib/oracle/12.2/instantclient

So that apache user will use those variable at runtime. And also check for user/group permission it has to be www-data:www-data



来源:https://stackoverflow.com/questions/47771132/php7-0-fpm-with-docker-unable-to-load-dynamic-library-oci8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!