您的位置:首页 > 运维架构 > Nginx

如何更改nginx网站根目录

2017-02-24 12:19 141 查看
默认网站根目录为/usr/local/nginx/html,要将它改成/home/ftpUser/www

vi /usr/local/nginx/conf/nginx.conf
将其中的

        location / {
            root   html;
            index  index.php index.html index.htm;
        }

改为

        location / {
            root  /home/ftpUser/www;
            index  index.php index.html index.htm;
        }

然后再将

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;
        }

改为

location ~ \.php$ {
            root           /home/ftpUser/www;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

然后重启nginx
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: