概述找不到应该根据configuration的vHostfind的PHP文件
我试图用Docker设置一个Symfony 3.x应用程序。 我通过docker-compose.yml文件configuration了3个docker容器:
Nginx的
PHP-FPM
MysqL的
当我导航到my-project.dev:8080/时,我看到一个简单的404-Not Found页面。
我无法加载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; }
我不得不通过创建一个像这样的图像覆盖PHP-fpm图像的workdir:
Dockerfile:
FROM PHP:5.6-fpm MAINTAINER Firstname Lastname <firstname.lastname@domain.com> workdir /var/www
构建图像:
docker build -t companyx/PHP-5.6-fpm .
更新docker-compose文件:
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: companyx/PHP-5.6-fpm volumes: – .:/var/www links: – db db: image: MysqL:latest volumes: – /var/lib/MysqL environment: – MysqL_ROOT_PASSWORD=my-password
问题是,用你的定义:
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; }
你正在使用返回404的PHP页面。
你应该改变行try_files $uri /app.PHP$is_args$args; 在
try_files $uri /app_dev.PHP$is_args$args;
总结
以上是内存溢出为你收集整理的找不到应该根据configuration的vHostfind的PHP文件全部内容,希望文章能够帮你解决找不到应该根据configuration的vHostfind的PHP文件所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
请登录后查看评论内容