zoukankan      html  css  js  c++  java
  • 更改Nginx网站根目录以及导致的403 forbidden问题解决

    版权声明:本文为博主原创文章,未经博主允许不得转载。

    一、更改根目录

    Nginx默认网站根目录为/usr/local/nginx/html,要将它改成/home/fuxiao/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,网站根目录就已经是我们的家目录下的www。
     
    二、解决403错误
     
    但更改完成后进行测试,访问www下的网页一直提示403 forbidden,如下图
     
    开始以为是自己访问的网页不具有读权限,于是给网页授予了读权限,但更改后再次访问依旧是该错误,试了多种方法后发现问题出在/home/fuxiao目录的fuxiao不具备读权限,即我们普通用户起初不具备读权限,只需给该目录赋予读权限即可解决该403问题。
  • 相关阅读:
    Algorithm Gossip (37) 快速排序法 ( 一 )
    Algorithm Gossip (36) Heap排序法( 堆排序 )
    Algorithm Gossip (35) Shaker法
    Algorithm Gossip (34) 希尔排序
    AlgorithmGossip (33) 选择、插入、气泡排序
    Algorithm Gossip (32) 得分排行
    Algorithm Gossip (31) 数字拆解(dp问题)
    Algorithm Gossip (30) m元素集合的 n 个元素子集
    Algorithm Gossip (29) 产生可能的集合
    Algorithm Gossip (27) 排列组合
  • 原文地址:https://www.cnblogs.com/webnote/p/6120553.html
Copyright © 2011-2022 走看看