CentOS 7 + Nginx + Google Compute Engine (permission forbidden error)
CentOS 7 + Nginx + Google Compute Engine (permission forbidden error)
我对 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 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 并且仍然相同错误仍然出现
我错过了什么?
是 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
我对 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 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 并且仍然相同错误仍然出现
我错过了什么?
是 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