nginx php403错误,Nginx服务器中403 forbidden 错误解决

本文详细记录了在配置Nginx两个虚拟主机后,遇到客户端无法访问新增Server的问题及解决过程。错误日志显示权限被拒绝,通过检查目录权限、Nginx启动进程,发现worker进程权限配置不正确。最终通过修改nginx.conf文件,将user改为root并重新加载配置,成功解决了问题。
摘要由CSDN通过智能技术生成

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

05dca6cbf301b02293329908d065cb97.png

解决过程:

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. 再次访问,成功!

c22241e76605952057e19e8361067fcb.png

Nginx 的详细介绍:请点这里

Nginx 的下载地址:请点这里

0b1331709591d260c1c78e86d0c51c18.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值