How can I install a pecl extension like mcrypt in DDEV-Local's web container?

会有一股神秘感。 提交于 2020-04-16 02:27:47

问题


In PHP 7.2 and higher the mcrypt extension is no longer available, but my project depends on it. I know that the project shouldn't be using something as ancient as mcrypt, but I don't have any say in this. I know that mcrypt was removed from PHP7.2+ but is still in pecl.

What can I do for this project to support php-mcrypt in 7.2 and higher?


回答1:


DDEV-Local supports custom Dockerfiles, so you can add almost anything you want to the web container.

This .ddev/web-build/Dockerfile will install the mcrypt extension from pecl. It uses the techniques in the links in the question to build php-mcrypt for the PHP version in PHP_VERSION.

If you wanted to install a different pecl extension, you might need just a few less packages, but the idea is the same.


# 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


来源:https://stackoverflow.com/questions/60554989/how-can-i-install-a-pecl-extension-like-mcrypt-in-ddev-locals-web-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!