nginx下修改网站根目录方法

nginx下修改网站根目录方法

PHP编程 2016-11-08 12:54:42

nginx下修改网站根目录方法

nginx下修改网站根目录方法

分类: PHP编程时间: 2016-11-08

一般情况下nginx默认网站根目录为/usr/local/nginx/html,举个例子如果你要将它改成/home/www

只需找到配置文件nginx.conf

将其中的


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

改为


  location / {
            root   /home/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/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 OK!


相关文章