[英]Docker for nginx and php-fpm
I'm getting started with Docker
and docker-compose
我开始使用Docker
和docker-compose
My first step was to build a stack with 2 containers : 1 for nginx and 1 for php-fpm 我的第一步是用2个容器构建一个堆栈:1个用于nginx,另外1个用于php-fpm
With that config, it's working 使用该配置,它可以正常工作
version: '3.3'
services:
web:
image: nginx
ports:
- "9090:80"
volumes:
- ./conf/default.conf:/etc/nginx/conf.d/default.conf:ro
- ./content:/usr/share/nginx/html:ro
links:
- php
php:
image: php:7.1.8-fpm
volumes:
- ./content:/usr/share/nginx/html:ro
In /content
I have both a index.html
and phpinfo.php
在/content
我同时拥有index.html
和phpinfo.php
I can get both pages in my browser. 我可以在浏览器中找到两个页面。
But I don't understand why I have to put all my pages in both containers ? 但是我不明白为什么我必须将所有页面都放在两个容器中?
If I don't put the volume for the php service
, the index.html is displaying but not the phpinfo.php (File not found.) 如果我不为php service
放置卷,则显示index.html,但不显示phpinfo.php(未找到文件。)
If I don't put the volume for the web service
, the nginx index.html is displaying but not the phpinfo.php (404 error). 如果我不为web service
放置卷,则显示nginx index.html而不显示phpinfo.php(404错误)。
So now if I want to deploy a wordpress site I will have to copy all the files in both containers ? 因此,现在如果我想部署wordpress网站,我将不得不复制两个容器中的所有文件?
Bad configuration. 配置错误。 Good practice is to separate all processes, so you should have 3 services: nginx, php-fpm and php. 好的做法是分离所有进程,因此您应该拥有3个服务:nginx,php-fpm和php。 Source code should be ONLY inside php container. 源代码只能在php容器内。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.