centos 无法加载模块:无法加载模块:Uniform to loaded to load--.

wpx232ag  于 2022-11-07  发布在  其他
关注(0)|答案(1)|浏览(201)

我是一个在服务器上设置Oracle数据库的新手,我正在CentOS7服务器(centos-release-7-7.1908.0.el7.centos.x86_64)上使用Docker设置NGINX PHP-FPM 7.4 Alpine和Oracle数据库。
我已经成功地在Docker中安装了Oracle数据库,所以我的下一个目标是能够使用PHP中的oci_connect函数连接到Oracle数据库。这就是我卡住的地方。我一直在遵循这个目标并下载所需的软件,如Oracle Instant Client。(在撰写本文时,我使用的是最新版本:客户端-基本-Linux. x64 -19.6.0.0.0dbru)
我得到了以下文件的docker-compose:

停靠-撰写.yml:

version: '3'
services:
  web:
    image: nginx:alpine
    ports:
      - 8080:80
    volumes:
      - ./web:/var/www/web
      - ./log:/var/log/nginx
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf
      - ./nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf
    restart: always
  phpfpm:
    build:
      context: ./php-fpm
      dockerfile: Dockerfile
    volumes:
      - ./web:/var/www/web

php-fpm/停靠文件:

FROM php:7.4-fpm-alpine

RUN mkdir -p /var/www/web

# custom.ini is basically my php.ini

ADD custom.ini /usr/local/etc/php/conf.d/custom.ini

RUN apk add --update --no-cache \
    libzip-dev \
    curl-dev \
    libxml2-dev \
    libpng-dev \
    $PHPIZE_DEPS \
    php7-openssl

RUN docker-php-ext-configure gd

RUN docker-php-ext-install \
    curl \
    dom \
    gd \
    json \
    tokenizer \
    zip 

# Install Oracle Instantclient

RUN mkdir /opt/oracle \
    && cd /opt/oracle 

ADD instantclient-basic-linux.x64-19.6.0.0.0dbru.zip /opt/oracle/instantclient-basic-linux.x64-19.6.0.0.0dbru.zip
ADD instantclient-sdk-linux.x64-19.6.0.0.0dbru.zip /opt/oracle/instantclient-sdk-linux.x64-19.6.0.0.0dbru.zip

RUN rm -rf /opt/oracle/instantclient_19_6/*

RUN unzip /opt/oracle/instantclient-basic-linux.x64-19.6.0.0.0dbru.zip -d /opt/oracle \
    && unzip /opt/oracle/instantclient-sdk-linux.x64-19.6.0.0.0dbru.zip -d /opt/oracle \
    && ln -sf /opt/oracle/instantclient_19_6/libclntsh.so.19.1 /opt/oracle/instantclient_19_6/libclntsh.so \
    && ln -sf /opt/oracle/instantclient_19_6/libclntshcore.so.19.1 /opt/oracle/instantclient_19_6/libclntshcore.so \
    && ln -sf /opt/oracle/instantclient_19_6/libocci.so.19.1 /opt/oracle/instantclient_19_6/libocci.so \
    && rm -rf /opt/oracle/*.zip

# Install Oracle extensions

RUN docker-php-ext-configure pdo_oci --with-pdo-oci=instantclient,/opt/oracle/instantclient_19_6,19.1 \
       && echo 'instantclient,/opt/oracle/instantclient_19_6/' | pecl install oci8 \
       && docker-php-ext-install \
               pdo_oci \
       && docker-php-ext-enable \
               oci8

RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/community/ --allow-untrusted gnu-libiconv
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php

EXPOSE 9000

CMD ["php-fpm"]

此外,我还将这些与Oracle相关的“扩展”添加到custom.ini(基本上是我的php.ini)中,这在上面的php-fpm/Dockerfile中引用:

expose_php = Off
extension=oci8.so
extension=pdo_oci.so

扩充合成

当我执行docker-composite up时,我看到构建过程可以完成,但在构建输出中遇到以下警告:

...
...

Installing shared extensions:     /usr/local/lib/php/extensions/no-debug-non-zts-20190902/
PHP Warning:  PHP Startup: Unable to load dynamic library 'oci8.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20190902/oci8.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20190902/oci8.so: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20190902/oci8.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20190902/oci8.so.so: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_oci.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20190902/pdo_oci.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20190902/pdo_oci.so: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20190902/pdo_oci.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20190902/pdo_oci.so.so: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'oci8.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20190902/oci8.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20190902/oci8.so: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20190902/oci8.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20190902/oci8.so.so: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_oci.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20190902/pdo_oci.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20190902/pdo_oci.so: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20190902/pdo_oci.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20190902/pdo_oci.so.so: No such file or directory)) in Unknown on line 0

...
...

此“无法加载动态库”oci8.so“和”pdo_oci.so“”在构建中出现大约20次。
整个构建过程完成后,php-fpm会运行,但也会出现类似的警告消息:

Successfully built c5fe0a0bc6ab
Successfully tagged nginx-php_phpfpm:latest
Starting nginx-php_web_1    ... done
Creating nginx-php_phpfpm_1 ... done
Attaching to nginx-php_web_1, nginx-php_phpfpm_1
phpfpm_1  | [20-Mar-2020 11:30:03] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library 'oci8.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20190902/oci8.so (Error loading shared library libnsl.so.1: No such file or directory (needed by /opt/oracle/instantclient_19_6//libclntsh.so.19.1)), /usr/local/lib/php/extensions/no-debug-non-zts-20190902/oci8.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20190902/oci8.so.so: No such file or directory)) in Unknown on line 0
phpfpm_1  | [20-Mar-2020 11:30:03] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_oci.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20190902/pdo_oci.so (Error loading shared library libnsl.so.1: No such file or directory (needed by /opt/oracle/instantclient_19_6/libclntsh.so.19.1)), /usr/local/lib/php/extensions/no-debug-non-zts-20190902/pdo_oci.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20190902/pdo_oci.so.so: No such file or directory)) in Unknown on line 0
phpfpm_1  | [20-Mar-2020 11:30:03] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library 'oci8.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20190902/oci8.so (Error loading shared library libnsl.so.1: No such file or directory (needed by /opt/oracle/instantclient_19_6//libclntsh.so.19.1)), /usr/local/lib/php/extensions/no-debug-non-zts-20190902/oci8.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20190902/oci8.so.so: No such file or directory)) in Unknown on line 0
phpfpm_1  | [20-Mar-2020 11:30:03] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_oci.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20190902/pdo_oci.so (Error loading shared library libnsl.so.1: No such file or directory (needed by /opt/oracle/instantclient_19_6/libclntsh.so.19.1)), /usr/local/lib/php/extensions/no-debug-non-zts-20190902/pdo_oci.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20190902/pdo_oci.so.so: No such file or directory)) in Unknown on line 0
phpfpm_1  | [20-Mar-2020 11:30:03] NOTICE: fpm is running, pid 1
phpfpm_1  | [20-Mar-2020 11:30:03] NOTICE: ready to handle connections

PHP测试

我还用一个.php文件对此进行了测试:

<?php

  $objConnect = oci_connect('SYSTEM', 'xxxxxxxxxx', 'x.x.x.x');
    if($objConnect)
    {
        echo "Oracle Server Connected";
    }     
?>

显然,这在浏览器上产生:

Fatal error: Uncaught Error: Call to undefined function oci_connect() in /var/www/web/public/index.php:3 Stack trace: #0 {main} thrown in /var/www/web/public/index.php on line 3

"看着集装箱"
我还试着往容器本身看了看:docker exec -it 623 sh以签入应用程序引用的目录:

/usr/local/lib/php/extensions/no-debug-non-zts-20190902 # ls -la
total 2588
drwxr-xr-x    1 root     root            39 Mar 20 11:29 .
drwxr-xr-x    1 root     root            39 Mar 19 22:43 ..
-rwxr-xr-x    1 root     root        122288 Mar 20 11:28 curl.so
-rwxr-xr-x    1 root     root        249824 Mar 20 11:28 dom.so
-rwxr-xr-x    1 root     root        433280 Mar 20 11:29 gd.so
-rwxr-xr-x    1 root     root         54944 Mar 20 11:29 json.so
-rw-r--r--    1 root     root        911808 Mar 20 11:29 oci8.so
-rwxr-xr-x    1 root     root        579504 Mar 19 22:43 opcache.so
-rwxr-xr-x    1 root     root         51368 Mar 20 11:29 pdo_oci.so
-rwxr-xr-x    1 root     root        108128 Mar 19 22:43 sodium.so
-rwxr-xr-x    1 root     root         35952 Mar 20 11:29 tokenizer.so
-rwxr-xr-x    1 root     root         89600 Mar 20 11:29 zip.so

我看到所有的文件都在那里,那么Unable to load dynamic library 'oci8.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20190902/oci8.so是怎么回事呢?当它在容器中时,为什么它找不到库呢?

我尝试过的其他方法:

我也试过查看StackOverflow,并尝试了这个X1 E0 F1 X,但仍然,将X1 M3 N1 X添加到我的DockerFile中并不能解决问题。
在这种情况下,我是否遗漏了什么?我必须做些什么才能为库解决它?或者在这种情况下是否存在一些不兼容问题?

kknvjkwl

kknvjkwl1#

添加到您的Dockerfile:


# ORACLE EXTENSION

RUN apt-get update && apt-get -y install wget bsdtar libaio1 && \
    wget -qO- https://raw.githubusercontent.com/caffeinalab/php-fpm-oci8/master/oracle/instantclient-basic-linux.x64-12.2.0.1.0.zip | bsdtar -xvf- -C /usr/local && \
    wget -qO- https://raw.githubusercontent.com/caffeinalab/php-fpm-oci8/master/oracle/instantclient-sdk-linux.x64-12.2.0.1.0.zip | bsdtar -xvf-  -C /usr/local && \
    wget -qO- https://raw.githubusercontent.com/caffeinalab/php-fpm-oci8/master/oracle/instantclient-sqlplus-linux.x64-12.2.0.1.0.zip | bsdtar -xvf- -C /usr/local && \
    ln -s /usr/local/instantclient_12_2 /usr/local/instantclient && \
    ln -s /usr/local/instantclient/libclntsh.so.* /usr/local/instantclient/libclntsh.so && \
    ln -s /usr/local/instantclient/lib* /usr/lib && \
    ln -s /usr/local/instantclient/sqlplus /usr/bin/sqlplus

RUN echo 'instantclient,/usr/local/instantclient/' | pecl install oci8 \
    && docker-php-ext-enable oci8 \
    && docker-php-ext-configure pdo_oci --with-pdo-oci=instantclient,/usr/local/instantclient \
    && docker-php-ext-install pdo_oci

相关问题