我对Nginx很新。我将Nginx配置为使用虚拟主机(服务器块)并重新启动nginx但是我收到两个对我没有意义的错误......
这是我的vhost服务器块的样子
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 Forbidden时,当我转到错误日志时它显示给我的内容
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设置为 BOTH " public_html"和" log"文件夹和我将所有者更改为" nginx:nginx"并重新启动nginx仍然出现相同的错误
我错过了什么?
答案 0 :(得分:2)
它是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