zoukankan      html  css  js  c++  java
  • nginx访问报错403 is forbidden

    由于开发需要,在本地环境中配置了nginx环境,使用的是Centos 6.5 的yum安装,安装一切正常,于是把网站文件用mv命令移动到了新的目录,并相应修改了配置文件,并重启Nginx。


    重启就报个“403 is forbidden“的错误,查看/var/log/nginx/error.log日志显示:xxx 403 forbidden (13: Permission denied)错误。


    引起nginx 403 forbidden通常是三种情况:一是缺少索引文件,二是权限问题,三是SELinux状态。


    一、缺少index.html或者index.php文件,就是配置文件中index index.html index.htm这行中的指定的文件。


    server {  
      listen       80;  
      server_name  localhost;  
      index  index.php index.html;  
      root  / var/www;
    }
    如果在/ var/www下面没有index.php,index.html的时候,直接访问域名,找不到文件,会报403 forbidden。


    二、权限问题,如果nginx没有web目录的操作权限,也会出现403错误。


    解决办法:修改web目录的读写权限,或者是把nginx的启动用户改成目录的所属用户,重启Nginx即可解决


    chmod -R 755 / var/www

    把nginx的启动用户改成目录的所属用户方法:
    vim /etc/nginx/nginx.conf


    user  yunva;


    三、SELinux设置为开启状态(enabled)的原因


    首先查看本机SELinux的开启状态,如果SELinux status参数为enabled即为开启状态


    /usr/sbin/ sestatus -v
    或者使用getenforce命令检查


    找到原因了,如何关闭 SELinux 呢


    1、临时关闭(不用重启)


    setenforce 0
    2、修改配置文件 /etc/ selinux/config,将SELINUX=enforcing改为SELINUX=disabled


    vi /etc/ selinux/config
  • 相关阅读:
    进程与线程
    the art of seo(chapter seven)
    the art of seo(chapter six)
    the art of seo(chapter five)
    the art of seo(chapter four)
    the art of seo(chapter three)
    the art of seo(chapter two)
    the art of seo(chapter one)
    Sentinel Cluster流程分析
    Sentinel Core流程分析
  • 原文地址:https://www.cnblogs.com/reblue520/p/6239733.html
Copyright © 2011-2022 走看看