我用PHP7.0-FPM和Apache 2.4创建了一个Docker镜像。我安装了InstantClient 12.2(基本+ sdk),我安装了oci8,如下所示:
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
我不知道为什么,但是当我(重新)启动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
oci8.so和libmql1.so的位置似乎还可以:
# 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*
我添加了/etc/php/7.0/fpm/pool.d/www.conf
这四行:
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
我会错过什么吗?
由于
答案 0 :(得分:0)
尝试在/ etc / apache2 / envvars中添加这些env变量 添加到文件末尾,如
export LD_LIBRARY_PATH = / usr / lib / oracle / 12.2 / instantclient
导出TNS_ADMIN = / etc / oracle
导出ORACLE_BASE = / usr / lib / oracle / 12.2 / instantclient
export ORACLE_HOME = / usr / lib / oracle / 12.2 / instantclient
这样apache用户将在运行时使用这些变量。 并且还要检查用户/组的权限,它必须是www-data:www-data
答案 1 :(得分:0)
没关系!
我错过了.conf
/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