1.更改根目录
Nginx默认网站根目录是/usr/local/nginx/html,需要修改为/home/fuxiao/www
如何改变:
?1vi/usr/local/nginx/conf/nginx.conf将
?1234location/{roothtml;indexindex.phpindex.htmlindex.htm;}改为
?1234location/{root/home/fuxiao/www;indexindex.phpindex.htmlindex.htm;}然后更改
?location~\.php${roothtml;fastcgi_pass127.0.0.1:9000;fastcgi_indexindex.php;fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;includefastcgi_params;}更改为
?location~\.php${root/home/fuxiao/www;fastcgi_pass127.0.0.1:9000;fastcgi_indexindex.php;fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;includefastcgi_params;}然后重启Nginx,网站根目录已经是我们的www了在主目录中。
2.解决403错误
但更改完成并测试后,访问www下的网页时,一直提示403禁止,如下图
解决方案
一开始我以为自己访问的网页没有读取权限,于是给该网页授予了读取权限。但是修改后,再次访问时还是报错。尝试了很多方法后发现问题是/home/fuxiao目录下的fuxiao没有读权限。权限,也就是我们普通用户一开始是没有读取权限的。我们只需要给该目录授予读权限就可以解决403问题。
总结
以上就是本文的全部内容。希望本文的内容能够对大家的学习或者工作有所帮助。如果您有任何疑问,可以留言沟通。