Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to solve the problem caused by the change of Nginx website root directory

Shulou Source: shulou.com Published: 2022-05-31 12:21:26 11月12日 Update

This article mainly explains "how to solve 403 caused by changes in the root directory of Nginx website", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "How to solve the 403 caused by the root directory change of Nginx website"!

Change the root directory

The requested URL/usr/local/nginx/html was not found on this server.

Change method:

vi /usr/local/nginx/conf/nginx.conf

of which

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

changed to

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

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

changed 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 root directory of the website is already www under our home directory.

403 Error

However, after the change is completed, the test is carried out. The webpage under www always prompts 403 forbidden, as shown in the following figure.

solution

At first, I thought that the webpage I visited did not have read permission, so I granted the read permission to the webpage, but after changing it, the error was still the same. After trying a variety of methods, I found that the problem was that the fuxiao in the/home/fuxiao directory did not have read permission, that is, our ordinary users did not have read permission at first. Just give the directory read permission to solve the 403 problem.

At this point, I believe that everyone has a deeper understanding of "how to solve 403 caused by changes in the root directory of Nginx website". Let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

Tags: Root directory website permissions methods directories web pages content errors problems learning practical ordinary deeper interest again just multiple practical practical easy to operate Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno vpn Huawei macOS NVidia