How to solve the Forbidden error of Nginx 403 caused by permission problem
This article mainly introduces "how to solve Nginx 403 Forbidden errors caused by permission problems". In daily operation, I believe many people have doubts about how to solve Nginx 403 Forbidden errors caused by permission problems. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer "how to solve Nginx 403 Forbidden errors caused by permission problems". Next, please follow the editor to study!
Today, when you install nginx on a new environment, you end up visiting 403s.
Usually when it shows 403, I immediately think that the path is not configured correctly, but I took a closer look at it and found that the directory path is fine:
Nginx.conf:
The copy code is as follows:
Server {
Listen 80
Server_name localhost
# charset koi8-r
# access_log logs/host.access.log main
Location / {
Root/ root/html
Index index.html index.htm
}
}
Path query results in the system:
The copy code is as follows:
[root@lizhong html] # ll / root/html/
Total dosage 4
-rw-r--r-- 1 root root 3 April 18 11:07 index.html
Directory exists, restart nginx or this error, later thought is not the permission problem? So add a line to the nginx.conf header:
The copy code is as follows:
User root
Restart nginx and access it again, and you can access it normally.
Restart nginx and access it again, and you can access it normally.
If you do not want to use the root user to run, you can solve the 403 problem by modifying the directory access rights, but you can also solve the permission problem by putting the directory under the root user host directory, putting it in any location and giving it 755, or changing its owner's identity to the nginx running identity through chown.
At this point, the study on "how to solve Nginx 403 Forbidden errors caused by permission problems" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!