Docker-php-ext-install mcrypt 缺少文件夹

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47671108/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 02:35:01  来源:igfitidea点击:

Docker-php-ext-install mcrypt missing folder

phpdockerdockerfilemcrypt

提问by Gerrit

I try to install mcrypt in my docker image based on php:7.2-apache. Therefore I use the RUN-Command from the documentation and also answerd herebut I receive this error:

我尝试在我的 docker 镜像中安装 mcrypt 基于php:7.2-apache. 因此,我使用文档中的 RUN-Command 并在此处回答但收到此错误:

error: /usr/src/php/ext/mcrypt does not exist


usage: /usr/local/bin/docker-php-ext-install [-jN] ext-name [ext-name ...]

   ie: /usr/local/bin/docker-php-ext-install gd mysqli
   /usr/local/bin/docker-php-ext-install pdo pdo_mysql
   /usr/local/bin/docker-php-ext-install -j5 gd mbstring mysqli pdo pdo_mysql shmop

if custom ./configure arguments are necessary, see docker-php-ext-configure

Possible values for ext-name:
bcmath bz2 calendar ctype curl dba dom enchant exif fileinfo filter ftp  gd gettext gmp hash iconv imap interbase intl json ldap mbstring mysqli oci8  odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell readline recode reflection session shmop simplexml snmp soap sockets sodium spl standard sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zend_test zip

Some of the above modules are already compiled into PHP; please check
the output of "php -i" to see which modules are already loaded.
ERROR: Service 'web' failed to build: The command '/bin/sh -c apt-get update && apt-get install -y          libfreetype6-dev          libjpeg62-turbo-dev          libmcrypt-dev          libpng-dev     && docker-php-ext-install -j$(nproc) iconv mcrypt gd mbstring zip' returned a non-zero code: 1

My Dockerfile:

我的 Dockerfile:

FROM php:7.2-apache

RUN apt-get update && apt-get install -y \
     libfreetype6-dev \
     libjpeg62-turbo-dev \
     libmcrypt-dev \
     libpng-dev \
&& docker-php-ext-install -j$(nproc) iconv mcrypt gd mbstring zip
#    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
#    && docker-php-ext-install -j$(nproc) gd


COPY ./etc/000-default.conf /etc/apache2/sites-available/

EXPOSE 80

Has anybody an idea how to solve or how to get the needed files in the requested folder?

有没有人知道如何解决或如何在请求的文件夹中获取所需的文件?

Thanks!

谢谢!

回答by MoiioM

mycryptextension is not provided with the PHP source since 7.2, but are instead available through PECL. To install a PECLextension in docker, use pecl installto download and compile it, then use docker-php-ext-enableto enable it:

7.2起 PHP 源代码中不再提供mycrypt扩展,而是通过PECL 提供。要在docker 中安装PECL扩展,请使用下载并编译它,然后使用启用它:pecl installdocker-php-ext-enable

pecl install mcrypt-1.0.3
docker-php-ext-enable mcrypt

回答by rlorenzo

Building on MoiioM's answer, this worked for me using the 7.2-stretch Docker image from PHP

基于 MoiioM 的回答,这对我使用来自PHP的 7.2-stretch Docker 图像有效

RUN apt-get update && apt-get install -y libmcrypt-dev \
    && pecl install mcrypt-1.0.2 \
    && docker-php-ext-enable mcrypt

回答by Tomasz

To install mcryptextension you have to make sure you did install libmcrypt-devwhich is required.

要安装mcrypt扩展,您必须确保安装了libmcrypt-dev所需的扩展。

Try to add:

尝试添加:

RUN apt install libmcrypt-dev

before you are trying to install extensions for php.

在您尝试安装 php 扩展之前。

Update

更新

Try to run first:

尝试先运行:

docker-php-ext-configure mcrypt

and then

进而

docker-php-ext-install mcrypt