如何在DDEV-Local的Web容器中安装像mcrypt这样的pecl扩展?

问题描述 投票:0回答:1

在PHP 7.2和更高版本中,不再提供mcrypt扩展,但是我的项目依赖于此。我知道该项目不应该使用像mcrypt这样古老的东西,但是我对此没有任何发言权。我知道mcrypt是removed from PHP7.2+,但仍然在pecl

该项目在7.2及更高版本中支持php-mcrypt怎么办?

php pear mcrypt pecl ddev
1个回答
0
投票

DDEV-Local支持自定义Dockerfile,因此您几乎可以将所需的任何内容添加到Web容器。

此.ddev / web-build / Dockerfile将从pecl安装mcrypt扩展。它使用问题链接中的技术为PHP_VERSION中的PHP版本构建php-mcrypt。

如果您想安装其他pecl扩展名,则可能只需要少一些软件包,但是想法是相同的。


# You can copy this Dockerfile.example to Dockerfile to add configuration
# or packages or anything else to your webimage
ARG BASE_IMAGE=drud/ddev-webserver:v1.13.1
FROM $BASE_IMAGE

ENV PHP_VERSION=7.3
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y -o Dpkg::Options::="--force-confnew" --no-install-recommends --no-install-suggests gcc make autoconf libc-dev pkg-config php-pear php${PHP_VERSION}-dev libmcrypt-dev
# The "echo" below just forces accepting the "automatic" configuration, the same as hitting <RETURN>
RUN echo | sudo pecl install mcrypt
# Because php7.1-mcrypt is already installed in web container we can just copy its mcrypt.ini
RUN cp /etc/php/7.1/mods-available/mcrypt.ini /etc/php/${PHP_VERSION}/mods-available/ && phpenmod mcrypt
© www.soinside.com 2019 - 2024. All rights reserved.