Solution to Nginx 403 Forbidden

Source: Internet
Author: User
Today, nginx is installed in a new environment, and all accesses are 403.
Normally, 403 is displayed and I will immediately think of incorrect path configuration, but I have carefully checked the directory path:
Nginx. conf:

 

The code is as follows: Copy code
Server {
Listen 80;
Server_name localhost;
 
# Charset KOI8-R;
 
# Access_log logs/host. access. log main;
 
Location /{
Root/html;
Index index.html index.htm;
        }
}

System path query results:

The code is as follows: Copy code

[Root @ lizhong html] # ll/root/html/
Total Usage 4
-Rw-r -- 1 root 3 April 18 11:07 index.html

The directory exists. Restart nginx or this error. Then I thought about permission issues? Add a line to the nginx. conf header:

The code is as follows: Copy code

User root;

Restart nginx and then access it.

 

If you do not want to use the root user to run the program, you can modify the directory access permission to solve the 403 problem. However, you cannot place the directory in the root user's home directory, place it in any location, and give it 755, you can also solve the permission issue by changing the operating identity of its owner and nginx through chown.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.