nginx之 [error] 6702#0:XXX is forbidden (13: Permission denied)

張衝andy發表於2017-06-14

問題描述: 配置完 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]# date
Thu Jun 15 04:01:27 CST 2017
2. 檢查許可權
[root@mysql03 ~]# ll
drwxr-xr-x. 2 root root 4096 Jun 15 03:59 html
[root@mysql03 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@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]# ll
drwxr-xr-x. 2 root root 4096 Jun 15 04:08 conf
在nginx.conf檔案的第一行加上 user root root;
[root@mysql03 nginx]# cat conf/nginx.conf
user root root;
5. 重新 reload nginx程式
[root@mysql03 nginx]# ./sbin/nginx -s reload
6. 再次訪問,成功!


 補充:如果配置不能正常訪問, 試參考 http://blog.csdn.NET/zhang123456456/article/details/73252148


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31383567/viewspace-2140751/,如需轉載,請註明出處,否則將追究法律責任。

相關文章