nginx 修改网站的根目录

一般nginx网站根目录在nginx.conf中配置

下图说明网站根目录在安装目录下的html目录

 

安装目录查找:whereis nginx

 

 修改网站根目录,就需要修改 location /下的root

location / {
root /home/nginx/html;
index index.html index.htm;
}

如果location ~ .php$ 没有被屏蔽也需要修改root

location ~ .php$ {
            root          /home/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生效
posted @ 2022-05-16 09:27  leihongnu  阅读(2406)  评论(0)    收藏  举报