简体   繁体   English

无法编辑 Docker 中的 php.ini 文件

[英]Cannot edit php.ini file in Docker

I'm trying to edit the php.ini inside Docker, so I need to do docker-compose up .我正在尝试在 Docker 中编辑 php.ini,所以我需要执行docker-compose up But every time I do docker-compose up , php.ini returns as it was before.但是每次我做docker-compose up , php.ini 都会像以前一样返回。

Better to mount the php.ini from the host, as docker-compose up will terminate the container and will launch a new container which does not container the modified php.ini.最好从主机挂载 php.ini,因为 docker-compose up 将终止容器并启动一个不包含修改后的 php.ini 的新容器。

volumes:
   - ./config/custom.php.ini:/etc/php(version)/apache2/conf.d/custom.php.ini

By default the scan directory for extra php files will look in the conf.d directory.默认情况下,额外 php 文件的扫描目录将在 conf.d 目录中查找。 These files will overwrite the settings of the main php.ini.这些文件将覆盖主 php.ini 的设置。 I tested this with the asp_tag option turning it Off and On.我用 asp_tag 选项将其关闭和打开对此进行了测试。 It works fine as long as you do the following below.只要您执行以下操作,它就可以正常工作。

The trick to making this work is to use docker-compose down instead of docker-compose kill完成这项工作的技巧是使用docker-compose down而不是docker-compose kill

you can check further here and here你可以在这里这里进一步检查

If you are using something like wodby ( docker4php or docker4drupal ) or lando or trying to find an answer "why php.ini doesn't work" (like me), these tools are using their own way to pass configuration into php如果您正在使用类似wodbydocker4phpdocker4drupal )或lando或试图找到答案“为什么 php.ini 不起作用”(像我一样),这些工具正在使用自己的方式将配置传递给 php

https://github.com/wodby/php#php-and-php-fpm-configuration https://github.com/wodby/php#php-and-php-fpm-configuration

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM