Today I installed nginx in a new environment, and the results were all 403
Usually 403 is displayed and I immediately think that the path configuration is wrong, but I looked carefully After a while, the directory path is OK:
nginx.conf:
Copy code The code is as follows:
server {
listen 80;
server_name localhost ;
#charset koi8-r;
# index index.html index.htm;
}
}
Path query results in the system:
Copy code The code is as follows:
[root@lizhong html]# ll /root/html/
Total usage 4
directory exists, and the error persists after restarting nginx. Later, I thought about whether it was a permissions issue? So add a line to the head of nginx.conf:
Copy the code The code is as follows:
user root;
Restart nginx and access again, you can access normally
If you don’t want to run as root user, you can solve the 403 problem by modifying the directory access permissions. But you cannot put the directory in the root user's host directory. Put it in any location and give it 755, or change its owner through chown to be consistent with the nginx running identity to solve the permission problem.
The above is the detailed content of How to solve Nginx 403 Forbidden error caused by permission issues. For more information, please follow other related articles on the PHP Chinese website!