can#39;t update php.ini file in Docker container(无法更新 Docker 容器中的 php.ini 文件)
问题描述
我正在尝试使用 Nginx & 在 Docker 上设置 Magento2PHP7.
I'm trying to set Magento2 on Docker with Nginx & PHP7.
按照
应该是:
memory_limit = 2G
max_execution_time = 800
我检查了 PHP 容器,可以看到 php.ini 文件的设置正确,或者我认为是这样?
I've checked the PHP container and I can see the php.ini file is there with the correct settings, or so I think?
$ docker exec -it mymagento2docker_php_1 /bin/bash
# cat /usr/local/etc/php/php.ini
; This file is created automatically by the docker build
memory_limit = 2G
max_execution_time = 800
我做错了什么?以下是更多详细信息,在此先感谢!
What am I doing wrong? Below are some more details, thanks in advance!
.
├── docker-compose.yml
├── index.php
├── magento2
│ ├── [DIRECTORIES & FILES OMMITED]
│
├── nginx
│ ├── Dockerfile
│ ├── default.conf
│ └── nginx.conf
├── output.txt
├── php
├── Dockerfile
└── config
└── php.ini
<小时>
docker-compose.yml
nginx:
build: ./nginx/
ports:
- 80:80
links:
- php
volumes_from:
- app
php:
build: ./php/
expose:
- 9000
links:
- mysql
volumes_from:
- app
app:
image: php:7.0-fpm
volumes:
- ./magento2:/var/www/html
command: "true"
mysql:
image: mysql:latest
volumes_from:
- data
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: mage2
MYSQL_DATABASE: mage2
MYSQL_USER: mage2
MYSQL_PASSWORD: mage2
data:
image: mysql:latest
volumes:
- /var/lib/mysql
command: "true"
phpmyadmin:
image: phpmyadmin/phpmyadmin
ports:
- 8080:80
links:
- mysql
environment:
PMA_HOST: mysql
<小时>
php/Dockerfile
FROM php:7.0-fpm
# Install dependencies
RUN apt-get update
&& apt-get install -y
cron
libfreetype6-dev
libicu-dev
libjpeg62-turbo-dev
libmcrypt-dev
libpng12-dev
libxslt1-dev
# Configure the gd library
RUN docker-php-ext-configure
gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
# Install required PHP extensions
RUN docker-php-ext-install
gd
intl
mbstring
mcrypt
pdo_mysql
xsl
zip
soap
# Install the 2.4 version of xdebug that's compatible with php7
RUN pecl install -o -f xdebug-2.4.0
COPY config/php.ini /usr/local/etc/php/
<小时>
## php/config/php.ini ##
; This file is created automatically by the docker build
memory_limit = 2G
max_execution_time = 800
更新
我试过用下面的方法重启nginx,但是没用.
UPDATE
I've tried restarting nginx with the below, but it did not work.
$ docker exec -it mymagento2docker_php_1 /bin/bash
# /etc/init.d/nginx restart
bash: /etc/init.d/nginx: No such file or directory
# service nginx restart
nginx: unrecognized service
# nginx -s reload
bash: nginx: command not found
# exit
$ docker restart mymagento2docker_nginx_1
mymagento2docker_nginx_1
$ docker exec -it mymagento2docker_nginx_1 /bin/bash
# /etc/init.d/nginx restart
Restarting nginx: nginxross in ~/my-magento2-docker
$ docker-compose ps
Name Command State Ports
---------------------------------------------------------------------------------------------
mymagento2docker_app_1 true Exit 0
mymagento2docker_data_1 docker-entrypoint.sh true Exit 0
mymagento2docker_mysql_1 docker-entrypoint.sh mysqld Up 0.0.0.0:3306->3306/tcp
mymagento2docker_nginx_1 nginx -g daemon off; Exit 0
mymagento2docker_php_1 php-fpm Up 9000/tcp
mymagento2docker_phpmyadmin_1 /run.sh phpmyadmin Up 0.0.0.0:8080->80/tcp
ross in ~/my-magento2-docker
$ docker-compose up -d
Starting mymagento2docker_app_1
Starting mymagento2docker_data_1
mymagento2docker_mysql_1 is up-to-date
mymagento2docker_phpmyadmin_1 is up-to-date
mymagento2docker_php_1 is up-to-date
Starting mymagento2docker_nginx_1
ross in ~/my-magento2-docker
$ docker exec -it mymagento2docker_nginx_1 /bin/bash
# service nginx restart
Restarting nginx: nginxross in ~/my-magento2-docker
$ docker-compose up -d
Starting mymagento2docker_app_1
Starting mymagento2docker_data_1
mymagento2docker_mysql_1 is up-to-date
mymagento2docker_phpmyadmin_1 is up-to-date
mymagento2docker_php_1 is up-to-date
Starting mymagento2docker_nginx_1
ross in ~/my-magento2-docker
$ docker exec -it mymagento2docker_nginx_1 /bin/bash
# nginx -s reload
2016/10/05 14:07:43 [notice] 12#12: signal process started
#
推荐答案
在 docker-compose.yml 中的 php 服务中添加 volumes: 部分 文件,将带有 custom.ini 文件的本地目录映射到 /usr/local/etc/php/conf.d,然后重新启动容器.该文件中的任何有效设置都将覆盖主 php.ini 文件中的设置.(顺便说一句,你可以用 MySQL 做同样的事情,但不能用 Nginx).
Add a volumes: section to your php service in the docker-compose.yml file, map a local directory with a custom.ini file to /usr/local/etc/php/conf.d, and restart your container. Whatever valid settings in that file will override those from the main php.ini file. (Incidentally you can do the same with MySQL but not with Nginx).
这适用于我自己的项目:
This works in my own project:
<代码>php:卷:- ./localpath/custom.ini:/usr/local/etc/php/conf.d/custom.ini
这篇关于无法更新 Docker 容器中的 php.ini 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:无法更新 Docker 容器中的 php.ini 文件
基础教程推荐
- Libpuzzle 索引数百万张图片? 2022-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- 在多维数组中查找最大值 2021-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01