更改根目录
Nginx默认网站根目录为/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/fuxiao/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/fuxiao/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。
解决403错误
更改完成后进行测试,访问www下的网页可能会提示403 forbidden
解决方法
问题出在/home/ftpuser目录的ftpuser不具备读权限,可以将该文件夹及子文件夹权限修改 777 即可
chmod 777 ftpuser