我对Nginx相当陌生。我将 Nginx 配置为使用虚拟主机(服务器块)并重新启动 nginx,但我遇到了两个对我来说毫无意义的错误......
这就是我的虚拟服务器块的样子
server {
listen 80 default_server;
listen [::]:80 default_server;
root /custom/path/to/public_html;
index index.html index.htm index.php;
server_name _;
#access_log /custom/path/to/log/oq.default.access.log combined buffer=1024k;
#error_log /custom/path/to/log/oq.default.error.log;
location / {
try_files $uri $uri/ =404;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
错误号#1:在注释掉access_log行之前,nginx 将无法启动,并显示以下错误2017/01/23 02:10:23 [emerg] 26984#0: open() "/custom/path/to/log/oq.default.access.log" failed (13: Permission denied)
错误号 #2:注释掉access_log行后,重新启动nginx(成功),那时我在我的网站上收到错误403禁止,当我转到错误日志时,它向我显示了什么
2017/01/23 11:32:10 [error] 5812#0: *3 "/custom/path/to/public_html/index.html" is forbidden (13: Permission denied), client: xxx.xxx.xxx.xxx, server: _, request: "GET / HTTP/1.1", host: "xxx.xxx.xxx.xxx"
我将 777 设置为"public_html "和"日志"文件夹,我将所有者更改为"nginx:nginx"并重新启动 nginx,但仍然出现相同的错误
我错过了什么?
它是 SELinux:
grep nginx /var/log/audit/audit.log | audit2allow -m nginx > nginx.te
cat nginx.te
grep nginx /var/log/audit/audit.log | audit2allow -M nginx
semodule -i nginx.pp