我正在嘗試使用Docker安裝Symfony 3.x應用程序。 我通過搬運工-compose.yml文件中配置3個搬運工容器:找不到應該根據配置找到的PHP文件vHost
- Nginx的
- PHP-FPM
- 的MySQL
當我導航到my-project.dev:8080/ ,我看到一個簡單的404-未找到頁面。
- 我不能加載my-project.dev:8080/app_dev.php或my-project.dev:8080/config.php(我得到一個 「找不到文件」 的錯誤)
我在/var/log/nginx/access.log中也看不到任何條目。
泊塢窗,compose.yml:
web:
image: nginx:latest
ports:
- "8080:80"
volumes:
- .:/var/www
- ./docker/vhost.conf:/etc/nginx/sites-enabled/vhost.conf
- ./docker/nginx.conf:/etc/nginx/nginx.conf
links:
- php
php:
image: php:5.6-fpm
volumes:
- .:/var/www
links:
- db
db:
image: mysql:latest
volumes:
- /var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=my-password
nginx.conf文件:
user www-data;
worker_processes 4;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
vhost.conf文件:
server {
listen *:80;
server_name my-project.dev;
root /var/www/web;
location/{
# try to serve file directly, fallback to app.php
try_files $uri /app.php$is_args$args;
}
# DEV
# This rule should only be placed on your development environment
# In production, don't include this and don't deploy app_dev.php or config.php
location ~ ^/(app_dev|config)\.php(/|$) {
fastcgi_pass php:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}
location ~ \.php$ {
return 404;
}
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
}
我不知道泊塢什麼...但你的虛擬主機不需要也必須被告知監聽8080端口?你有什麼東西在8080上聽嗎? 'grep「8080」/ etc/nginx/sites-available/*'會返回任何內容嗎? –
嗨達倫,謝謝你的回覆。我發現是什麼導致了這個問題:我忘了爲php-fpm image +添加'volume'配置屬性+我不得不從/ var/www/html覆蓋/ var/www中的「WORKDIR」 php-fpm圖像。 – mattyh88