nginx配置DocumentRoot
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Nginx的$document_root 的参数是由root html那一行定义的,默认是在/etc/nginx/html/所以把 html换成站点根目录就可以了。
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
本文介绍了如何在Nginx中配置PHP处理程序,通过设置location指令匹配PHP文件,并指定root路径指向站点根目录,使用fastcgi_pass指令连接到PHP-FPM服务。此外还展示了如何传递SCRIPT_FILENAME参数并包含fastcgi_params文件。
353

被折叠的 条评论
为什么被折叠?



