Nginx 403 Forbidden Solution _nginx

Source: Internet
Author: User

Common, causes the Nginx 403 forbidden to have two kinds of reasons, first is the missing index file, two permissions question.

1, missing index.html or index.php files

Copy Code code as follows:
server {
Listen 80;
server_name localhost;
Index index.php index.html;
root/var/www;
}

If there is no index.php,index.html under the/var/www, direct access to the domain name, can not find the file, will be reported 403 forbidden.
For example: You access www.test.com and this domain name, corresponding to the root specified by the index file does not exist.
2, Permission issues
For PHP, this error can result if the Nginx user does not have permission to the Web directory.
Workaround: Modify the Web directory's read and write permissions, or change the Nginx user to the directory of the user, a restart can be resolved. Such as:
Copy Code code as follows:

Chown-r Nginx_user:nginx_user/htdocs


"Note": Do not forget to restart the Nginx service after modifying the configuration

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.