我尝试根据php:7.2-apache
在我的泊坞窗图片中安装mcrypt。因此,我使用文档中的RUN-Command并回答了here但是我收到了这个错误:
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
我的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
有人知道如何解决或如何在所请求的文件夹中获取所需文件吗?
谢谢!
答案 0 :(得分:74)
mycrypt 扩展名,但可以通过 PECL 获得。要在docker中安装 PECL 扩展程序,请使用pecl install
下载并编译它,然后使用docker-php-ext-enable
启用它:
pecl install mcrypt-1.0.2
docker-php-ext-enable mcrypt
答案 1 :(得分:5)
要安装mcrypt
扩展程序,您必须确保安装了必需的libmcrypt-dev
。
尝试添加:
RUN apt install libmcrypt-dev
在您尝试安装php的扩展名之前。
<强>更新强>
尝试先跑:
docker-php-ext-configure mcrypt
然后
docker-php-ext-install mcrypt
答案 2 :(得分:1)
基于MoiioM的答案,这对我来说非常有效,它使用了PHP的7.2拉伸Docker镜像
RUN apt-get update && apt-get install -y libmcrypt-dev \
&& pecl install mcrypt-1.0.2 \
&& docker-php-ext-enable mcrypt