我正在尝试为位于不同文件夹中的多项目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 /,但收到了NginxFile not found
错误。
在nginx调试日志中,我看到以下信息。它似乎开始可以很好地解析位置和内容,但最终以结束/usr/share/nginx...
,我没有在conf中进行配置。我不是开发者,所以我不知道该如何解决。
2019/09/18 23:14:21 [debug] 2720#2720:* 4 http脚本var:“ / ardu-component /” 2019/09/18 23:14:21 [debug] 2720#2720:* 4试用使用文件:“ / ardu-component /”“ / srv / www / ardu-component / ardu-component /” 2019/09/18 23:14:21 [debug] 2720#2720:* 4 http脚本副本:“ /index.php“ 2019/09/18 23:14:21 [debug] 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脚本var:“ / usr / share / nginx / html“ 2019/09/18 23:14:21 [调试] 2720#2720:* 4 http脚本var:” /index.php“ 2019/09/18 23:14:
提前致谢。
首先,如果server_name(您的本地主机)设置为本地主机
第二个设置您的/ srv / www
码
server {
location ~ /\. { deny all; }
listen *:80 ;
server_name localhost ;
root /srv/www;
location / {root /srv/www/;
index index.htm index.html index.php;
}
location ^~ /ardu-component {
try_files $uri /index.php$is_args$args;
}
location ~ ^/.+\.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/lecad/public_html/$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param PHP_ADMIN_VALUE "open_basedir=\"/srv/www/:/tmp:/usr/local/lib/php:\"
include_path=\"/usr/lib/php:/usr/local/lib/php:/tmp:/srv/www/\"";
include /etc/nginx/fastcgi_params;
}}
如果那不起作用,请尝试
更新
try_files $uri /index.php$is_args$args;
至
try_files /ardu-component/$uri /ardu-component/index.php$is_args$args;
希望对您有帮助
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句