【发布时间】:2020-01-19 21:28:24
【问题描述】:
我正在尝试为位于不同文件夹中的多项目 php 设置 nginx 配置文件。我的生产服务器中有以下配置文件。
server {
listen 80;
error_log /LOGS/ardu_error.log debug;
access_log /LOGS/ardu_access.log;
set $applicationEnv "production";
location ~ /ardu-component/ {
root /srv/www/ardu-component/;
try_files $uri /index.php$is_args$args;
}
location ~ ^/index\.php(/|$) {
# the ubuntu default
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param APPLICATION_ENV $applicationEnv;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}
#return 404 for all php files as we do have a front controller
location ~ \.php$ {
return 404;
}
}
server {
listen 80;
error_log /LOGS/ardu_error.log debug;
access_log /LOGS/ardu_access.log;
set $applicationEnv "production";
location ~ /ardu-component/ {
root /srv/www/ardu-component/;
try_files $uri /index.php$is_args$args;
}
location ~ ^/index\.php(/|$) {
# the ubuntu default
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param APPLICATION_ENV $applicationEnv;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}
#return 404 for all php files as we do have a front controller
location ~ \.php$ {
return 404;
}
}
我打开浏览器并尝试连接到 /ardu-component/ 并从 nginx 收到 File not found 错误。
在 nginx 调试日志中,我看到以下信息。它似乎开始很好地解决位置和东西,但它最终以/usr/share/nginx... 结束,我没有在 conf.xml 中配置它。我不是devops,所以我不知道如何解决这个问题。
2019/09/18 23:14:21 [调试] 2720#2720: *4 http 脚本变量: “/ardu-component/” 2019/09/18 23:14:21 [调试] 2720#2720: *4 试图 使用文件:“/ardu-component/”“/srv/www/ardu-component/ardu-component/” 2019/09/18 23:14:21 [调试] 2720#2720: *4 http 脚本副本: "/index.php" 2019/09/18 23:14:21 [调试] 2720#2720: *4 http 脚本 var: "" 2019/09/18 23:14:21 [debug] 2720#2720: *4 试图使用文件: "/index.php" "/srv/www/ardu-component/index.php" 2019/09/18 23:14:21 [调试] 2720#2720:*4 内部重定向:“/index.php?” 2019/09/18 23:14:21 [调试] 2720#2720:*4 重写阶段:1 ... 2019/09/18 23:14:21 [调试] 2720#2720: *4 http 脚本变量: “/usr/share/nginx/html” 2019/09/18 23:14:21 [调试] 2720#2720: *4 http 脚本变量:“/index.php”2019/09/18 23:14:21 [调试] 2720#2720: *4 fastcgi 参数:“SCRIPT_FILENAME:/usr/share/nginx/html/index.php” 2019/09/18 23:14:21 [调试] 2720#2720: *4 http 脚本副本:“HTTPS” 2019/09/18 23:14:21 [调试] 2720#2720: *4 http 脚本副本:“关闭” 2019/09/18 23:14:21 [debug] 2720#2720: *4 fastcgi param: "HTTPS: off"
提前致谢。
【问题讨论】: