在Dockerfile中安装并启用PHP的OCI8扩展:8.1-fpm
我正在尝试在dockerfile中安装和启用OCI8的php:8.1-fpm 图像到..
这是我的dockerfile的一部分:
RUN mkdir /opt/oracle
# Install Oracle Instantclient
RUN wget https://download.oracle.com/otn_software/linux/instantclient/216000/instantclient-basic-linux.x64-21.6.0.0.0dbru.zip \
&& wget https://download.oracle.com/otn_software/linux/instantclient/216000/instantclient-sdk-linux.x64-21.6.0.0.0dbru.zip \
&& wget https://download.oracle.com/otn_software/linux/instantclient/216000/instantclient-sqlplus-linux.x64-21.6.0.0.0dbru.zip \
&& unzip instantclient-basic-linux.x64-21.6.0.0.0dbru.zip -d /opt/oracle \
&& unzip instantclient-sdk-linux.x64-21.6.0.0.0dbru.zip -d /opt/oracle \
&& unzip instantclient-sqlplus-linux.x64-21.6.0.0.0dbru.zip -d /opt/oracle \
&& rm -rf *.zip \
&& mv /opt/oracle/instantclient_21_6 /opt/oracle/instantclient
#add oracle instantclient path to environment
ENV LD_LIBRARY_PATH /opt/oracle/instantclient/
RUN ldconfig
# Install Oracle extensions
RUN docker-php-ext-configure pdo_oci --with-pdo-oci=instantclient,/opt/oracle/instantclient,21.1 \
&& echo 'instantclient,/opt/oracle/instantclient/' | pecl install oci8 \
&& docker-php-ext-install \
pdo_oci \
&& docker-php-ext-enable \
oci8
完整的dockerfile 是在
这里代码> docker -compose build :成功地使用此警告构建:
Warning: PHP Startup: Unable to load dynamic library 'pdo_oci.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20210902/pdo_oci.so (Error loading shared library libaio.so.1: No such file or directory (needed by /usr/local/instantclient_21_6/libclntsh.so.21.1)), /usr/local/lib/php/extensions/no-debug-non-zts-20210902/pdo_oci.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20210902/pdo_oci.so.so: No such file or directory)) in Unknown on line 0
当我使用运行php -m
在安装后使用警告后,我发现了,我发现了这一点OCI8未安装。
那么如何修复呢?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
起初,我认为这是一个路径问题,但是在警告消息的一部分中很明显的真正错误:
错误加载共享库libaio.so.1:no这样的文件或目录
此命令显示
oci8.so
的缺失库是什么是什么:输出:
输出所说:
libaio.so.1
缺少。我通过安装这些软件包解决了它:
编辑:
我最近尝试重建dockerfile的相同版本,并且我在执行此命令时特别是安装了OCI8的错误:
错误:
错误:失败:无法解决:无法解决。 :process“/bin/sh -c echo'instantClient,/opt/oracle/intermantclient/'| pecl install oci8”未能成功完成:退出代码:1
在仔细搜索构建的输出之后,有关错误的更多信息,我在此行中发现了问题:
#Error使用PHP OCI8 3.2用于您的PHP版本
我不知道为什么它以前工作了,我认为最近添加了此特定版本的要求,因此我更改了命令以安装该特定版本OCI8
At first I thought it was a path issue, but the real error which was clear in part of the warning message:
Error loading shared library libaio.so.1: No such file or directory
also this command shows what is exactly the missing libraries for
oci8.so
:output:
as the output says:
libaio.so.1
is missing.I solved it by Installing these packages:
Edit:
I tried to rebuild the same version of the Dockerfile lately and I got an error installing OCI8, specifically while executing this command:
ERROR: failed to solve: process "/bin/sh -c echo 'instantclient,/opt/oracle/instantclient/' | pecl install oci8" did not complete successfully: exit code: 1
after a careful search in the output of the build for more info about the error I found the problem in this line:
#error Use PHP OCI8 3.2 for your version of PHP
I don't know why it was working before, I think this specific version requirement was added lately, So simply I changed the command to install that specific version of OCI8
在安装PHP扩展程序之前,设置系统库搜索路径以包含即时客户端库。最好的方法是按照 ldconfig #ic_x64_inst“ rel =“ nofollow noreferrer”>即时客户端安装指令。在您的情况下,这将是:
这也意味着您可以从步骤
运行ld_library_path =/usr/usr/local/instantclient_21_6/php
中删除ld_library_path。实际上,整行没有用。您可能会在 docker for node.js和python中的oracle数据库应用程序有用。
Set the system library search path to contain the Instant Client libraries before installing the PHP extensions. The best way is to use
ldconfig
as recommended in the Instant Client installation instructions. In your case it would be:This would also mean you can remove LD_LIBRARY_PATH from the step
RUN LD_LIBRARY_PATH=/usr/local/instantclient_21_6/ php
. In fact, that whole line isn't useful.You may find some of the Instant Client tips in Docker for Oracle Database Applications in Node.js and Python useful.