阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Nginx服务器中403 forbidden 错误解决

167次阅读
没有评论

共计 1757 个字符,预计需要花费 5 分钟才能阅读完成。

问题描述:配置完 Nginx 两个虚拟机后,客户端能够访问原始的 Server , 新增加的 Server 虚拟机 不能够访问,报错如下页面

Nginx 服务器中 403 forbidden 错误解决

解决过程:

1. 查看报错日志
[root@linuxidc nginx]# cat logs/error.log
2017/06/15 04:00:57 [error] 6702#0: *14 “/root/html/index.html” is forbidden (13: Permission denied), client: 10.219.24.1, server: www.linuxidc.com, request: “GET / HTTP/1.1”, host: “www.linuxidc.com”
[root@linuxidc logs]# date
Thu Jun 15 04:01:27 CST 2017

2. 检查权限
[root@linuxidc ~]# ll
drwxr-xr-x. 2 root root 4096 Jun 15 03:59 html
[root@linuxidc html]# ll
total 8
-rw-r–r–. 1 root root 537 Jun 15 03:59 50x.html
-rw-r–r–. 1 root root 616 Jun 15 03:51 index.html
说明:发现目录权限没有问题

3. 检查 nginx 启动进程
[root@linuxidc logs]# ps anx|grep nginx
6546 ? Ss 0:00 nginx: master process ./sbin/nginx
6702 ? S 0:00 nginx: worker process
6726 pts/1 S+ 0:00 grep nginx
说明:发现 nginx 的 work process 是 nobody 的

4. 修改 nginx.conf 文件
打开 nginx.conf 文件所在的目录,查看文件的属性(root root)
[root@linuxidc nginx]# ll
drwxr-xr-x. 2 root root 4096 Jun 15 04:08 conf
在 nginx.conf 文件的第一行加上 user root root;
[root@linuxidc nginx]# cat conf/nginx.conf
user root root;

5. 重新 reload nginx 进程
[root@linuxidc nginx]# ./sbin/nginx -s reload

6. 再次访问,成功!

Nginx 服务器中 403 forbidden 错误解决

CentOS 7 下 Nginx 服务器的安装配置  http://www.linuxidc.com/Linux/2017-04/142986.htm

CentOS 上安装 Nginx 服务器实现虚拟主机和域名重定向  http://www.linuxidc.com/Linux/2017-04/142642.htm

CentOS 6.8 安装 LNMP 环境(Linux+Nginx+MySQL+PHP)http://www.linuxidc.com/Linux/2017-04/142880.htm

Linux 下安装 PHP 环境并配置 Nginx 支持 php-fpm 模块  http://www.linuxidc.com/Linux/2017-05/144333.htm

Nginx 服务的 SSL 认证和 htpasswd 认证  http://www.linuxidc.com/Linux/2017-04/142478.htm

Linux 中安装配置 Nginx 及参数详解  http://www.linuxidc.com/Linux/2017-05/143853.htm

Nginx 日志过滤 使用 ngx_log_if 不记录特定日志 http://www.linuxidc.com/Linux/2014-07/104686.htm

CentOS 7.2 下 Nginx+PHP+MySQL+Memcache 缓存服务器安装配置  http://www.linuxidc.com/Linux/2017-03/142168.htm

CentOS6.9 编译安装 Nginx1.4.7  http://www.linuxidc.com/Linux/2017-06/144473.htm

Nginx 的详细介绍:请点这里
Nginx 的下载地址:请点这里

本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-06/144827.htm

 

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-01-21发表,共计1757字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中