自从PHP 7.1更新到PHP 7.2后,我无法安装oci8。我有这个错误:
root @ 3ab6027c8d95:/ var / www #php -v
PHP警告:PHP启动:无法加载动态库'oci8.so'(试过:/usr/local/lib/php/extensions/no-debug-non-zts-20170718/oci8.so(libmql1.so) :无法打开共享对象文件:没有这样的文件或目录),/ usr / local / lib / php / extensions / no-debug-non-zts-1701/170 / / / / / / extensions / no-debug-non-zts-20170718 / oci8.so.so:无法打开共享对象文件:没有这样的文件或目录))在第0行的Unknown中
PHP 7.2.0(cli)(建于:2017年12月12日05:52:58)(NTS) 版权所有(c)1997-2017 PHP小组 Zend Engine v3.2.0,版权所有(c)1998-2017 Zend Technologies Zend Technologies的Zend OPcache v7.2.0,Copyright(c)1999-2017,
我正在使用Docker环境,我为此创建了一个github repo,如果我使用PHP的版本 7.1 (shenron/docker-php-fpm:7.2),它就可以工作。
我不明白为什么脚本会尝试启动此文件:/usr/local/lib/php/extensions/no-debug-non-zts-20170718/oci8.so.so
。
就我而言,有两种可能性;或者驱动程序不兼容,或者pecl今天无法安装oci8。
有没有人有同样的问题?
感谢您的帮助。
答案 0 :(得分:8)
/usr/local/lib/php/extensions/no-debug-non-zts-20170718/oci8.so.so
只是对共享库文件名的第二次猜测。你可以放心地忽略它。
实际问题是:(tried: /usr/local/lib/php/extensions/no-debug-non-zts-20170718/oci8.so (libmql1.so: cannot open shared object file: No such file or directory)
oci8.so
本身依赖于多个共享库,您可以使用ldd
找出哪些库:
ldd /usr/local/lib/php/extensions/no-debug-non-zts-20170718/oci8.so
linux-vdso.so.1 (0x00007ffc8bfe7000)
libclntsh.so.12.1 => /usr/local/instantclient/libclntsh.so.12.1 (0x00007fb9919e0000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb991641000)
libmql1.so => not found
libipc1.so => not found
libnnz12.so => not found
libons.so => not found
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fb99143d000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fb991139000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fb990f1c000)
libnsl.so.1 => /lib/x86_64-linux-gnu/libnsl.so.1 (0x00007fb990d04000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fb990afc000)
/lib64/ld-linux-x86-64.so.2 (0x00007fb994bc8000)
libaio.so.1 => /lib/x86_64-linux-gnu/libaio.so.1 (0x00007fb9908fa000)
libclntshcore.so.12.1 => not found
这些.so
文件似乎是存储库中zip文件的一部分。
像这样运行PHP LD_LIBRARY_PATH=/usr/local/instantclient_12_1/ php
在容器内运行正常。您需要将这些文件移动到理智的位置。
答案 1 :(得分:3)
对于任何遇到这个问题的人,这是在Linux中处理它的正确方法。 (我在下面的演示中使用CentOS命令,但Ubnutu应该没有什么不同)
编辑:感谢Christopher Jones的评论,您可以在https://yum.oracle.com/repo/OracleLinux/OL7/oracle/instantclient/x86_64/上找到直接rpm链接
wget oracle-instantclient18.3-basic-18.3.0.0.0-1.x86_64.rpm
wget oracle-instantclient18.3-devel-18.3.0.0.0-1.x86_64.rpm
yum install oracle-instantclient18.3-basic-18.3.0.0.0-1.x86_64.rpm
yum install oracle-instantclient18.3-devel-18.3.0.0.0-1.x86_64.rpm
sudo sh -c "echo /usr/lib/oracle/18.3/client64/lib > /etc/ld.so.conf.d/oracle.conf"
sudo ldconfig
php -v
# and you should get something like
PHP 7.2.12 (cli) (built: Nov 6 2018 16:40:25)...
答案 2 :(得分:0)
如果运行ldd /usr/local/lib/php/extensions/no-debug-non-zts-20170718/oci8.so
会给您这样的信息,但文件丢失:
ldd /usr/local/lib/php/extensions/no-debug-non-zts-20170718/oci8.so
linux-vdso.so.1 (0x00007ffc8bfe7000)
libclntsh.so.12.1 => /usr/local/instantclient/libclntsh.so.12.1 (0x00007fb9919e0000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb991641000)
libmql1.so => not found
libipc1.so => not found
libnnz12.so => not found
libons.so => not found
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fb99143d000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fb991139000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fb990f1c000)
libnsl.so.1 => /lib/x86_64-linux-gnu/libnsl.so.1 (0x00007fb990d04000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fb990afc000)
/lib64/ld-linux-x86-64.so.2 (0x00007fb994bc8000)
libaio.so.1 => /lib/x86_64-linux-gnu/libaio.so.1 (0x00007fb9908fa000)
libclntshcore.so.12.1 => not found
您可以像这样将文件夹添加到ldconfig中(其他读者-您的路径可能有所不同):
echo /usr/local/instantclient_12_1/ > /etc/ld.so.conf.d/oracle-instantclient.conf
然后运行ldconfig
以读取新配置。
答案 3 :(得分:0)
将此添加到我的Dockerfile中:
# Install Oracle instantclient and oci8 extension
RUN mkdir /opt/oracle \
&& curl 'https://download.oracle.com/otn_software/linux/instantclient/19600/instantclient-basic-linux.x64-19.6.0.0.0dbru.zip' --output /opt/oracle/instantclient-basic-linux.zip \
&& curl 'https://download.oracle.com/otn_software/linux/instantclient/19600/instantclient-sdk-linux.x64-19.6.0.0.0dbru.zip' --output /opt/oracle/instantclient-sdk-linux.zip \
&& unzip '/opt/oracle/instantclient-basic-linux.zip' -d /opt/oracle \
&& unzip '/opt/oracle/instantclient-sdk-linux.zip' -d /opt/oracle \
&& rm /opt/oracle/instantclient-*.zip \
&& mv /opt/oracle/instantclient_* /opt/oracle/instantclient \
&& docker-php-ext-configure oci8 --with-oci8=instantclient,/opt/oracle/instantclient \
&& docker-php-ext-install oci8 \
&& echo /opt/oracle/instantclient/ > /etc/ld.so.conf.d/oracle-insantclient.conf \
&& ldconfig
libaio1也需要重新安装。