当我尝试使用nginx访问域时,我收到403禁止错误。我得到的nginx日志是:
[error] 13656#0: *4 "/var/www/example.com/www/index.php" is forbidden (13: Permission denied), client: 31.179.107.194, server: example.com, request: "GET / HTTP/1.1", host: "example.com"
/var/www/
具有递归777权限。站点可用的配置是:
#HTTP serve
#
server {
listen 80;
root /var/www/example.com/www/;
index index.php index.html index.htm;
server_name example.com;
access_log /var/log/nginx/example.com.access.log combined buffer=1024k;
error_log /var/log/nginx/example.com.error.log;
client_max_body_size 128M;
if (!-e $request_filename) {
rewrite ^/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/$ /index.php?controller=$1&action=$2 last;
}
location ~ \.php$ {
if (!-f $document_root/$fastcgi_script_name){
return 404;
}
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
proxy_connect_timeout 600s;
proxy_read_timeout 600s;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
nginx.conf包含user root;
指令。
怎么了?
答案 0 :(得分:0)
一个可能的原因是您正在使用SELinux。请参阅Why does Nginx return a 403 even though all permissions are set properly?。
此外,设置user root
是一种安全风险,不建议这样做。使用非特权用户,例如' www-data'或者“没人”#39;建议使用允许该用户访问所需最少量数据的权限。