Nginx Access Error 403 is forbidden

Source: Internet
Author: User
Tags log log php file
Due to development needs, in the local environment to configure the Nginx environment, using the installation of the CentOS 6.5 yum, install all normal, so the website files with the MV command moved to the new directory, and modify the configuration file, and restart Nginx.


Restart on a "403 is forbidden" error, view/var/log/nginx/error.log log display: XXX 403 Forbidden (13:permission denied) error.


Cause Nginx 403 Forbidden is usually three cases: one is the missing index file, the second is the permission problem, and the third is the SELinux state.


The missing index.html or index.php file is the specified file in the configuration file in the index index.html index.htm this line.


server {
Listen 80;
server_name localhost;
Index index.php index.html;
root/var/www;
}
If there is no index.php,index.html under/var/www, direct access to the domain name, cannot find the file, will be reported 403 forbidden.


Second, permissions issues, if Nginx does not have the Web directory operation permissions, there will also be a 403 error.


Workaround: Modify the Web directory read and write permissions, or to the user to change the Nginx startup user directory, restart Nginx can be resolved


Chmod-r 755/var/www

To change the Nginx startup user to the directory's user-owned method:
Vim/etc/nginx/nginx.conf


User Yunva;


Third, the reason that SELinux is set to On state (enabled)


Check the on state of the native SELinux first, if the SELinux status parameter is enabled


/usr/sbin/sestatus-v
or use the Getenforce command to check


Find out why, how to close SELinux?


1. Temporary shutdown (no restart)


Setenforce 0
2, modify the configuration file/etc/selinux/config, change selinux=enforcing to Selinux=disabled


Vi/etc/selinux/config

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.