Nginx site root directory changes and causes 403 Forbidden problem Resolution

Source: Internet
Author: User
Tags 403 forbidden error

Recently because of the work needs, to the Nginx site root directory changes, through some online tutorial changes, but found that the test has been prompted 403 Forbidden error, backstage through a friend's tips also solved, so now will be detailed steps to share to everyone, the need for friends can refer to learning.

First, change the root directory

Nginx Default Web site root directory is/usr/local/nginx/html, you want to change it to/home/fuxiao/www

Change method:

?
1 vi/usr/local/nginx/conf/nginx.conf

Put one of the

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

Switch

?
1234 location / {  root  /home/fuxiao/www;  index index.php index.html index.htm;}

And then we will

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

Switch

?
1234567 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 of www.

Ii. Resolving 403 Errors

But after the change is done, the Web page under WWW has been prompted to 403 forbidden, such as

Workaround

began to think that the Web page you visited does not have Read permission, so give the page Read permission, but after the change again access is still the error, after trying a variety of methods found that the problem in the/home/fuxiao directory Fuxiao do not have Read permission, that is, our ordinary users do not have Read permission at first, Just give the directory Read permission to resolve the 403 issue.

Summarize

The above is the entire content of this article, I hope that the content of this article on everyone's study or work can bring certain help, if there is doubt you can message exchange.

Nginx site root directory changes and causes 403 Forbidden problem Resolution

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.