问题描述: 配置完 nginx 两个虚拟机后,客户端能够访问原始的server ,新增加的 server 虚拟机 不能够访问,报错如下页面
解决过程:
1. 查看报错日志
[root@mysql03 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.nginx02.com, request: "GET / HTTP/1.1", host: "www.nginx02.com"[root@mysql03 logs]# dateThu Jun 15 04:01:27 CST 20172. 检查权限[root@mysql03 ~]# lldrwxr-xr-x. 2 root root 4096 Jun 15 03:59 html[root@mysql03 html]# lltotal 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@mysql03 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@mysql03 nginx]# lldrwxr-xr-x. 2 root root 4096 Jun 15 04:08 conf在nginx.conf文件的第一行加上 user root root;[root@mysql03 nginx]# cat conf/nginx.confuser root root;5. 重新 reload nginx进程[root@mysql03 nginx]# ./sbin/nginx -s reload6. 再次访问,成功!