全新安装 CentOS 7 和 nginx 1.6.3。官方文档我将 access_log 指令设置为通过 syslog 转发到 /etc/nginx/nginx.conf 中的远程服务器:
#access_log /var/log/nginx/access.log main;
access_log syslog:server=[10.1.2.3],facility=local7,tag=nginx,severity=info;
当我使用该更改重新启动(或启动)nginx 时,出现以下错误:
[root@localhost ~]# systemctl restart nginx
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
[root@localhost ~]# systemctl status nginx.service
(...)
nginx: [emerg] open() "/usr/share/nginx/syslog:server=[10.1.2.3],facility=local7,tag=nginx,severity=info" failed (13: Permission denied)
(...)
就好像服务不知道如何正确解析自己的配置文件,就好像 IP 和选项是它试图读取的文件的一部分。有人能解决这个问题吗,我是不是漏掉了什么明显的东西?
答案1
您有旧的 nginx。
Logging to syslog is available since version 1.7.1. As part of our commercial subscription logging to syslog is available since version 1.5.3.