Nginx服务器中403 forbidden 错误解决

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

Nginx服务器中403 forbidden 错误解决

解决过程:

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 错误解决

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

 

相关推荐