gpt4 book ai didi

php - 在 Dockerfile 中为 php :8. 1-fpm 安装并启用 OCI8 扩展

转载 作者:行者123 更新时间:2023-12-04 18:58:42 26 4
gpt4 key购买 nike

我正在尝试在 dockerfile 中为 php:8.1-fpm 安装和启用 OCI8
图像到..
这是我的 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 here 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
当我使用 RUN php -m 检查退出的扩展时安装完成后出现警告,我发现没有安装oci8。
那么如何解决呢?

最佳答案

在安装 PHP 扩展之前,设置系统库搜索路径以包含 Instant Client 库。最好的方法是使用ldconfig正如 Instant Client installation instructions 中的建议.在您的情况下,它将是:

RUN echo /usr/local/instantclient_21_6/ > /etc/ld.so.conf.d/oic.conf && \
ldconfig
这也意味着您可以从步骤 RUN LD_LIBRARY_PATH=/usr/local/instantclient_21_6/ php 中删除 LD_LIBRARY_PATH .事实上,整条线都没有用。
您可以在 Docker for Oracle Database Applications in Node.js and Python 中找到一些 Instant Client 提示。有用。

关于php - 在 Dockerfile 中为 php :8. 1-fpm 安装并启用 OCI8 扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72592165/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com