How can I override ddev's php-fpm.conf or pool.d/www.conf?

无人久伴 提交于 2021-01-29 05:14:42

问题


There is no obvious way to override some php-fpm configuration in DDEV-Local's web container. Although it's easy to provide custom PHP configuration it's not as obvious how one would configure the php-fpm process itself.

In my case I want to change the security.limit-extensions value in pool.d/www.conf


回答1:


There are two ways to do this. I'll create two separate answers to explain how.

The first technique is to create a custom Dockerfile (docs) which edits the www.conf (or any other file). You can also use the Dockerfile ADD command to add a complete file and override them.

In the case of this specific problem, we'll create a .ddev/web-build/Dockerfile with these contents:

# You can copy this Dockerfile.example to Dockerfile to add configuration
# or packages or anything else to your webimage
ARG BASE_IMAGE
FROM $BASE_IMAGE
ENV PHP_VERSION=7.4
RUN echo "security.limit_extensions = .php .html" >> /etc/php/${PHP_VERSION}/fpm/pool.d/www.conf

After you ddev start you'll have the new configuration.

Instead of the RUN echo approach that just appends to the file, given here for simplicity, you could RUN a sed/awk/perl statement to change the file in place.

And alternatively you could put the version of the www.conf that you want into the .ddev/web-build directory and

COPY www.conf /etc/php/${PHP_VERSION}/fpm/pool.d/www.conf



回答2:


The second way to approach this is to use a custom docker-compose.*.yaml file (docs.

Here you'll copy the desired www.conf (or any other file) into your project's .ddev directory and then mount it into the web container on top of the previously provided one. For this specific example, you can copy the www.conf into the .ddev folder by cd .ddev && docker cp ddev-<projectname>-web:/etc/php/7.4/fpm/pool.d/www.conf . and edit it as you need to (edit it with "security.limit_extensions = .php .html").

Then a custom .ddev/docker-compose.*.yaml file like this can mount it into the proper directory (mine is called docker-compose.wwwconf.yaml):

version: "3.6"
services:
  web:
    volumes:
    - "./www.conf:/etc/php/7.4/fpm/pool.d/www.conf"


来源:https://stackoverflow.com/questions/65693404/how-can-i-override-ddevs-php-fpm-conf-or-pool-d-www-conf

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