nginx 403 forbidden的一种情况

Nginx是一款性能强大的Web 服务器/反向代理服务器,截至至今年春季,世界Alexa排名前1000的网站中38.8%的使用nginx,超过Apache和IIS。

Nginx的配置不算复杂,但有时自己配置的server,无论如何也不能正常工作,页面提示403 Forbidden,察看日志可能是这样的提示

2011/03/13 20:28:01 [error] 31856#0: *4 "/root/nginx/html/index.html" is forbidden (13: Permission denied), client: 192.168.2.20, server: localhost, request: "GET / HTTP/1.1", host: "192.168.2.64:8080"
2011/03/13 20:28:01 [error] 31856#0: *4 open() "/root/nginx/html/favicon.ico" failed (13: Permission denied), client: 192.168.2.20, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "192.168.2.64:8080"
2011/03/13 20:33:38 [error] 31856#0: *5 "/root/nginx/html/index.html" is forbidden (13: Permission denied), client: 192.168.2.20, server: localhost, request: "GET / HTTP/1.1", host: "192.168.2.64:8080"
2011/03/13 20:33:38 [error] 31856#0: *5 open() "/root/nginx/html/favicon.ico" failed (13: Permission denied), client: 192.168.2.20, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "192.168.2.64:8080"

我把/root/nginx这个目录下所有的文件,文件夹的owner 改成 nginx:nginx 都不能解决这个问题,刚开始觉得奇怪,后来把nginx文件夹,移到/var目录下就可以了。

原来,nginx需要任何父层级的目录都有nginx用户读的权限。

linux  nginx  403 
2014-11-03 15:52