dockeroci8

Unable to load dynamic library 'oci8.so' (PHP 7.3)


I'm using Docker environment, when I upload Docker I get this error:

PHP Warning: PHP Startup: Unable to load dynamic library 'oci8' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20180731/oci8 (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20180731/oci8: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20180731/oci8.so (Error loading shared library libnsl.so.1: No such file or directory (needed by /opt/oracle/instantclient_11_2/libclntsh.so.11.1))) 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-20180731/pdo_oci.so (Error loading shared library libnsl.so.1: No such file or directory (needed by /opt/oracle/instantclient_11_2/libclntsh.so.11.1)), /usr/local/lib/php/extensions/no-debug-non-zts-20180731/pdo_oci.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20180731/pdo_oci.so.so: No such file or directory)) in Unknown on line 0

PHP Warning: PHP Startup: Unable to load dynamic library 'oci8' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20180731/oci8 (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20180731/oci8: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20180731/oci8.so (Error loading shared library libnsl.so.1: No such file or directory (needed by /opt/oracle/instantclient_11_2/libclntsh.so.11.1))) 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-20180731/pdo_oci.so (Error loading shared library libnsl.so.1: No such file or directory (needed by /opt/oracle/instantclient_11_2/libclntsh.so.11.1)), /usr/local/lib/php/extensions/no-debug-non-zts-20180731/pdo_oci.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20180731/pdo_oci.so.so: No such file or directory)) in Unknown on line 0 I don't understand why the script try to launch this file: /usr/local/lib/php/extensions/no-debug-non-zts-20170718/oci8.so.so

I don't understand why the script try to launch this file:

/usr/local/lib/php/extensions/no-debug-non-zts-20170718/oci8.so.so

I tried some solutions seen in other threads around here, still without success. tried solution

My Dockerfile:

# Oracle
RUN mkdir /opt/oracle && cd /opt/oracle

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

RUN  unzip /opt/oracle/instantclient-basic-linux.x64-11.2.0.4.0.zip -d /opt/oracle \
    && unzip /opt/oracle/instantclient-sdk-linux.x64-11.2.0.4.0.zip -d /opt/oracle \
    && ln -s /opt/oracle/instantclient_11_2/libclntsh.so.11.1 /opt/oracle/instantclient_11_2/libclntsh.so \
    && ln -s /opt/oracle/instantclient_11_2/libclntshcore.so.11.1 /opt/oracle/instantclient_11_2/libclntshcore.so \
    && ln -s /opt/oracle/instantclient_11_2/libocci.so.11.1 /opt/oracle/instantclient_11_2/libocci.so \
    && rm -rf /opt/oracle/*.zip

ENV LD_LIBRARY_PATH /opt/oracle/instantclient_11_2:${LD_LIBRARY_PATH}

RUN docker-php-ext-configure oci8 --with-oci8=instantclient,/opt/oracle/instantclient_11_2
RUN docker-php-ext-install oci8
RUN docker-php-ext-enable oci8
RUN docker-php-ext-configure pdo_oci --with-pdo-oci=instantclient,/opt/oracle/instantclient_11_2,11.2
RUN docker-php-ext-install pdo_oci

Solution

  • Try adding a manual install of the libnsl package. E.g on Oracle Linux 8 you would do something like:

    RUN yum install -y libnsl
    

    There were some changes to libnsl since the older Oracle client libraries were released. I'm guessing you are using a 'newer' operating system version.

    The requirement to manually add libnsl is noted on the Instant Client installation instructions.

    I would also suggest updating from Oracle 11.