How to solve Nginx 403 Forbidden error caused by permission issues

WBOY
Release: 2023-05-23 10:16:34
forward
1505 people have browsed it

Today I installed nginx in a new environment, and the results were all 403

权限问题导致Nginx 403 Forbidden错误怎么解决

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

-rw-r--r-- 1 root root 3 April 18 11:07 index.html

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

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template