nginx出现403 Forbidden解决方法
由于开发需要,在本地环境中配置了LNMP环境,使用的是Centos 7.4 的源码安装,安装一切正常,但是由于默认网站文件夹比较奇葩,于是把网站文件用mv命令移动到了新的目录,并相应修改了配置文件,并重启Nginx。
那么好,问题来了!本以为重启就OK了。居然报个“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
三、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
注意:修改配置文件需要重启系统 reboot
四、安装discuz,提示报个“403 is forbidden“的错误
- chmod -R 755 ./html/
- chown nginx.nginx -R ./html/
- vim conf/nginx.conf 中的location / 下增加一个index.php
- vim /usr/local/nginx/html/bbs/install/index.php 第十二行注释了!下面的是这个注释掉的报错
thrown in /usr/local/nginx/html/bbs/install/index.php on line 12" while reading response header from upstream, client: 192.168.10.100, server: localhost, request: "GET /bbs/install/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.10.74"
nginx出现403 Forbidden解决方法的更多相关文章
- nagios报错HTTP WARNING: HTTP/1.1 403 Forbidden解决方法
Nagios--localhost报警:"WARNING: HTTP/1.1 403 Forbidden "解决方法: In dashboard it shows alert on ...
- Nginx 出现 403 Forbidden 最终解决方法
Nginx 出现 403 Forbidden 最终解决 步骤一: 检查目录权限.权限不足的就加个权限吧. 例子:chmod -R 755 / var/www 步骤二: 打开nginx.conf 例子: ...
- Destoon手机搜索点击提示 http 403 forbidden解决方法
以下是网上搜到的答案: 最近发现用destoon开发的手机版网站,在手机版百度搜素网站的时候,点击之后出现 http 403 forbidden的弹出窗.必须再次的刷新网页才可以打开网站.出现这个问题 ...
- python爬虫 403 Forbidden 解决方法
模拟浏览器打开网页: headers={ 'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, ...
- Centos75 解决Nginx出现403 forbidden(13: Permission denied)
Centos75 新安装的vm,nginx出现403 forbidden 一般为SELinux设置为开启状态(enabled)的原因 切为root ,执行: sed -i 's/SELINUX=enf ...
- [Linux] Nginx networking 403 Forbidden 静态文件不允许查看
nginx 的 403 Forbidden errors 表示你在请求一个资源文件但是nginx不允许你查看. 403 Forbidden 只是一个HTTP状态码,像404,200一样不是技术上的错误 ...
- Nginx 出现 403 Forbidden 最终解决
Nginx 出现 403 Forbidden 最终解决 步骤一: 检查目录权限.权限不足的就加个权限吧. 例子:chmod -R 755 / var/www 步骤二: 打开nginx.conf 例子: ...
- IDM下载百度资源出现403的解决方法
测试发现是受cookie的影响,百度为了防止用外部下载工具突破限速加入了cookie验证,因为一般的下载工具请求下载的时候不会附加cookie信息. IDM就是这样,它请求下载文件时只知道文件的下载地 ...
- Windows中Nginx配置nginx.conf不生效解决方法(路径映射)
Windows中Nginx配置nginx.conf不生效解决方法 今天在做Nginx项目的时候,要处理一个路径映射问题, location /evaluate/ { proxy_pass http:/ ...
随机推荐
- python基础:if判断与流程控制案例
# 1.使用while循环输出1 2 3 4 5 6 8 9 10 count = 0 while count < 11: if count == 7: count += 1 continue ...
- 说说lock到底锁谁(II)?
摘要 今天在园子里面有园友反馈关于[C#基础]说说lock到底锁谁?文章中lock(this)的问题.后来针对文章中的例子,仔细想了一下,确实不准确,才有了这篇文章的补充,已经对文章中的demo进行修 ...
- 【小知识】证明 $1$ 到 $n$ 的立方和公式
scb 发明了小学奥数(确信) Formula \(\sum\limits_{i=1}^n i^3 = (\sum\limits_{i=1}^n i)^2\) Provement 构造一个矩阵 \(a ...
- Go语言值,指针,引用类型
原文:https://www.jianshu.com/p/af42cb368cef ---------------------------------------------------- Go语言的 ...
- django.core.exceptions.ImproperlyConfigured: The included URLconf 's9luffycity.urls' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused
出现问题: $ python manage.py runserver 启动项目报错时候 raise ImproperlyConfigured(msg.format(name=self.urlconf_ ...
- CodeForces 839B - Game of the Rows | Codeforces Round #428 (Div. 2)
血崩- - /* CodeForces 839B - Game of the Rows [ 贪心,分类讨论] | Codeforces Round #428 (Div. 2) 注意 2 7 2 2 2 ...
- nginx反向代理tomcat 时,出现https redirect后变成http的问题解决方法
需要修改两个配置 1.nginx配置 location / { proxy_pass http://test-server; proxy_set_header Host $host; proxy_se ...
- Spring MVC ajax提交方式
使用jquery的ajax的方式来提交 第一种,以json对象的形式提交 var jsonData = { "name" : "zhangsan", " ...
- SQL Server 基础:ADO.NET
序言 Connection 主要提供与数据库的连接功能 Command 用于返回数据.修改数据.运行存储过程以及发送或检索参数信息的数据库命令 CommandType 获取或设置Command对象要执 ...
- Java实现浏览器大文件分片上传
上周遇到这样一个问题,客户上传高清视频(1G以上)的时候上传失败. 一开始以为是session过期或者文件大小受系统限制,导致的错误. 查看了系统的配置文件没有看到文件大小限制, web.xml中s ...