【发布时间】:2017-05-26 05:54:05
【问题描述】:
我尝试了许多建议,但无法使其发挥作用。
我想和NGINX-PHP合作创建一个docker-compose.yml文件。
这是我做的:
version: "2"
services:
nginx:
image: nginx:latest
restart: always
ports:
- "80:80"
- "443:443"
links:
- php
depends_on:
- php
expose:
- "80"
- "443"
volumes:
- ./www:/var/www/html
- ./config/nginx/site.conf:/etc/nginx/sites-available/default
- ./config/nginx/site.conf:/etc/nginx/sites-enabled/default
php:
image: php:7-fpm
restart: always
volumes:
- ./www:/var/www/html
Docker 图像运行没有错误,但是当我想访问 Nginx 时,我得到了这个:
欢迎使用 nginx!
如果看到这个页面,说明nginx web服务器安装成功 和工作。需要进一步配置。
有关在线文档和支持,请参阅 nginx.org。 nginx.com 上提供商业支持。
感谢您使用 nginx。
我尝试登录两个映像并检查卷。我还检查了是否可以从nginx ping php。一切似乎都很好......
这是我的Nginx 站点配置:
server {
server_name ncp-docker;
listen 80;
index index.php index.html index.htm;
root /var/www/html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location ~ /(inc|uploads/avatars) {
deny all;
}
}
【问题讨论】:
-
可能不相关,但您可能希望更新到 compose 版本 3,即当前版本 docs.docker.com/compose/compose-file
标签: php nginx docker docker-compose