Nginx site root changes and problems that cause 403 Forbidden _nginx

Source: Internet
Author: User

First, change the root directory

Nginx the default Web site root is/usr/local/nginx/html, change it to/home/fuxiao/www

To change the method:

Vi/usr/local/nginx/conf/nginx.conf

Will be one of the

    Location/{
      root  html;
      Index index.php index.html index.htm;
    }

To

    Location/{
      root  /home/fuxiao/www;
      Index index.php index.html index.htm;
    }

And then the

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

To

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

Then restart Nginx, the site root directory is already in our home directory under the www.

Ii. resolution of 403 errors

However, after the change is completed to test, visit the Web page under www has been prompted 403 forbidden, the following figure

Solving method

Start to think that the page you are visiting does not have Read permission, so give the page Read permission, but after the change again access is still the error, tried a variety of methods found that the problem in the/home/fuxiao directory Fuxiao does not have read permission, that is, our ordinary users do not have Read permission at first, You can solve the 403 problem by simply giving the directory Read permission.

Summarize

The above is the entire content of this article, I hope the content of this article for everyone's study or work can bring certain help, if you have questions you can message exchange.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.