准备通过Dockerfile构建php镜像,在使用docker-php-ext-install
安装mcrypt
扩展时遇到如下错误:
error: /usr/src/php/ext/mcrypt does not exist
mycrypt extension is not provided with the PHP source since 7.2 , but are instead available through PECL. To install a PECL extension in docker, use pecl install to download and compile it, then use docker-php-ext-enable to enable it:
php从7.2开始不再在源码里支持mcrypt扩展而转到pecl方式支持
pecl install mcrypt-1.0.1
docker-php-ext-enable mcrypt
版本切换到7.1再执行构建时问题没有复现,同时按照
pecl install mcrypt-1.0.1
docker-php-ext-enable mcrypt
的方式安装之后也没有出现上述问题
安装过程中提示(虽然不会影响最终结果)
WARNING: Ignoring APKINDEX.e3d33561.tar.gz: No such file or directory
doing apk update fixes the problem (updates the index).
Request: Improve the error message.
FROM daocloud.io/php:7.2-fpm-alpine
LABEL maintainer="lestat@lestat.me"
# 修改镜像源
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
# 安装依赖,核心扩展,pecl扩展,git,composer,npm工具
RUN apk update && apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
curl-dev \
imagemagick-dev \
libtool \
libxml2-dev \
postgresql-dev \
sqlite-dev \
libmcrypt-dev \
freetype-dev \
libjpeg-turbo-dev \
libpng-dev \
&& apk add --no-cache \
curl \
git \
imagemagick \
mysql-client \
postgresql-libs \
nodejs \
nodejs-npm \
# 配置npm中国镜像
&& npm config set registry https://registry.npm.taobao.org \
&& pecl install imagick \
&& pecl install mcrypt-1.0.1 \
&& docker-php-ext-enable mcrypt \
&& docker-php-ext-enable imagick \
&& docker-php-ext-install \
curl \
mbstring \
pdo \
pdo_mysql \
pdo_pgsql \
pdo_sqlite \
pcntl \
tokenizer \
xml \
zip \
&& docker-php-ext-install -j"$(getconf _NPROCESSORS_ONLN)" iconv \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j"$(getconf _NPROCESSORS_ONLN)" gd \
&& pecl install -o -f redis \
&& rm -rf /tmp/pear \
&& docker-php-ext-enable redis
# 安装composer并允许root用户运行
ENV COMPOSER_ALLOW_SUPERUSER=1
ENV COMPOSER_NO_INTERACTION=1
ENV COMPOSER_HOME=/usr/local/share/composer
RUN mkdir -p /usr/local/share/composer \
&& curl -o /tmp/composer-setup.php https://getcomposer.org/installer \
&& php /tmp/composer-setup.php --no-ansi --install-dir=/usr/local/bin --filename=composer --snapshot \
&& rm -f /tmp/composer-setup.* \
# 配置composer中国全量镜像
&& composer config -g repo.packagist composer https://packagist.phpcomposer.com
# 对其他容器开放9000端口
EXPOSE 9000
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。