Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 221

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report