在 PHP 7.2 及更高版本中,mcrypt 扩展不再可用,但我的项目依赖于它。我知道该项目不应该使用像 mcrypt 这样古老的东西,但我对此没有任何发言权。我知道 mcrypt 是从 PHP7.2+ 中删除 https://lukasmestan.com/install-mcrypt-extension-in-php7-2/但仍处于pecl https://pecl.php.net/package/mcrypt.
我该怎么做才能让这个项目在 7.2 及更高版本中支持 php-mcrypt?
DDEV 支持自定义 Dockerfile,因此您几乎可以将任何想要的内容添加到 Web 容器中。看docs https://ddev.readthedocs.io/en/stable/users/extend/customizing-images/#adding-extra-dockerfiles-for-webimage-and-dbimage.
此 .ddev/web-build/Dockerfile 将安装来自 pecl 的 mcrypt 扩展。它使用问题中链接中的技术为 DDEV_PHP_VERSION 中的 PHP 版本构建 php-mcrypt(由构建过程提供)。
如果您想安装不同的 pecl 扩展,您可能只需要更少的软件包,但想法是相同的。
RUN disable_xdebug
RUN if [ ! -f /usr/bin/sed ]; then ln -sf /bin/sed /usr/bin/sed; fi
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y -o Dpkg::Options::="--force-confnew" --no-install-recommends --no-install-suggests build-essential make autoconf libc-dev pkg-config php-pear php${DDEV_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 php${DDEV_PHP_VERSION}-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/${DDEV_PHP_VERSION}/mods-available/ && phpenmod mcrypt
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)