Php: docker-php-ext-install mcrypt build successfully while php startup error

Created on 18 Jan 2017  ·  5Comments  ·  Source: docker-library/php

the following is the error message:
PHP message: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/mcrypt.so' - Error loading shared library libmcrypt.so.4: No such file or directory (needed by /usr/local/lib/php/extensions/no-debug-non-zts-20151012/mcrypt.so) in Unknown on line 0

and this is my Dockfile:
## install mcrypt && ( \ apk add \ --no-cache \ libmcrypt-dev \ && docker-php-ext-configure mcrypt \ --with-mcrypt \ && docker-php-ext-install mcrypt \ && apk del \ libmcrypt-dev \ )
my base image is php:7.0-alpine
please help me!

Most helpful comment

@yosifkit
you win ! :+1: i remove the :

apk del --no-cache libmcrypt-dev

the problem is fixed but an new error comes :

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/mcrypt.so' - Error loading shared library libltdl.so.7: No such file or directory (needed by /usr/local/lib/php/extensions/no-debug-non-zts-20151012/mcrypt.so) in Unknown on line 0

after add libltdl ,this is worked !
now the code is following:

 apk add --no-cache \
                    libmcrypt-dev \
                    libltdl \
        && docker-php-ext-configure mcrypt \
        && docker-php-ext-install mcrypt 

All 5 comments

Please paste ALL your Dockerfile in a readable code block.

@bweston92
the all Dockerfile:

## 安装若干扩展的php-fpm-alpine-7.0.14

## 基于docker-library/php/7.0/fpm/alpine
## refer https://github.com/docker-library/php/blob/3ac528cf10d42f3f47dcb9ded3477781fb11f714/7.0/fpm/alpine/Dockerfile
## 默认安装的扩展@{
## cgi-fcgi core cytype curl date dom fileinfo filter ftp hash iconv json libxml mbstring mysqlnd
## openssl pcre PDO pdo_sqlite Phar posix readline Reflection session SimpleXML SPL sqlite3 standard
## tokenizer xml xmlreader xmlwriter zlib }

FROM registry.cn-hangzhou.aliyuncs.com/baykier-dev/php-fpm:1.0

## 开始
RUN set -ex \
    ## install pdo_mysql
    && ( \
        docker-php-ext-install  pdo_mysql \
    ) \
    ## install gd
    ## refer https://github.com/docker-library/php/issues/225
    && ( \
        apk add \
            --no-cache \
            freetype \
            libpng \
            libjpeg-turbo \
            freetype-dev \
            libpng-dev \
            libjpeg-turbo-dev\
        && docker-php-ext-configure gd \
            --with-gd \
            --with-freetype-dir=/usr/include/ \
            --with-png-dir=/usr/include/ \
            --with-jpeg-dir=/usr/include/ \

        && docker-php-ext-install gd \
        && apk del \
            --no-cache \
            freetype-dev \
            libpng-dev \
            libjpeg-turbo-dev \
    ) \
    ## install mcrypt
    && ( \
        apk add \
            --no-cache \
            libmcrypt-dev \
        && docker-php-ext-configure mcrypt \
            --with-mcrypt \
        && docker-php-ext-install  mcrypt \
        && apk del \
        libmcrypt-dev \
    )

## 保持不变
ENTRYPOINT ["docker-php-entrypoint"]

CMD ["php", "-a"]

the base image is build by docker-library/php/7.0/alpine/Dockerfile

I would bet the problem is on the apk del libmcrypt-dev, since it also deletes libmcrypt which is probably required for runtime.

/var/www/html # apk del libmcrypt-dev
WARNING: Ignoring APKINDEX.167438ca.tar.gz: No such file or directory
WARNING: Ignoring APKINDEX.a2e6dac0.tar.gz: No such file or directory
(1/2) Purging libmcrypt-dev (2.5.8-r7)
(2/2) Purging libmcrypt (2.5.8-r7)
Executing busybox-1.24.2-r12.trigger
OK: 16 MiB in 25 packages

If you adjust the install to be apk add --no-cache libmcrypt-dev libmcrypt, then it won't get removed with the dev package.

@yosifkit
you win ! :+1: i remove the :

apk del --no-cache libmcrypt-dev

the problem is fixed but an new error comes :

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/mcrypt.so' - Error loading shared library libltdl.so.7: No such file or directory (needed by /usr/local/lib/php/extensions/no-debug-non-zts-20151012/mcrypt.so) in Unknown on line 0

after add libltdl ,this is worked !
now the code is following:

 apk add --no-cache \
                    libmcrypt-dev \
                    libltdl \
        && docker-php-ext-configure mcrypt \
        && docker-php-ext-install mcrypt 

You should add libmcrypt to runtime dependencies and libmcrypt-dev to build dependencies. So libltdl is not necessary in your case.

Was this page helpful?
0 / 5 - 0 ratings