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