Ubuntu上的nginx:权限被拒绝

我是系统pipe理新手。 在Ubuntu上通过puppet安装nginx后,我得到以下输出:

[alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied) [warn] 1898#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1 [emerg] 1898#0: open() "/var/log/nginx/access.log" failed (13: Permission denied) 

我如何摆脱所有这些消息?

我不想直接使用命令行(chown / chmod),并在每次创build新服务器时重复使用。 因此,我想到了什么必须join到木偶清单。

在这种情况下,最好的系统pipe理员练习是什么:更改/ var / log / nginx的所有者/权限或将日志存储在不同的位置? 如果chown / chmod是要走的路,哪个特定的权限将确保最高级别的安全性?

我试过了,但没有帮助:

  file { '/var/log/nginx': ensure => directory, mode => '0755', owner => 'www-data', group => 'www-data', recurse => true } 

编辑:

 vagrant@precise64:~$ ps aux | grep [n]ginx root 1001 0.0 0.1 62908 1388 ? Ss 08:47 0:00 nginx: master process /usr/sbin/nginx www-data 1002 0.0 0.1 63260 1696 ? S 08:47 0:00 nginx: worker process www-data 1003 0.0 0.1 63260 1696 ? S 08:47 0:00 nginx: worker process www-data 1004 0.0 0.1 63260 1696 ? S 08:47 0:00 nginx: worker process www-data 1005 0.0 0.1 63260 1696 ? S 08:47 0:00 nginx: worker process vagrant@precise64:~$ sudo chown -R www-data:www-data /var/log/nginx; vagrant@precise64:~$ sudo chmod -R 755 /var/log/nginx; vagrant@precise64:~$ ls -l /var/log/nginx/ -rwxr-xr-x 1 www-data www-data 214 Sep 10 11:07 error.log 

这可以帮助你。

您收到的消息是由于您以非root用户身份启动nginx或不使用sudo

为了摆脱log dir错误,你必须检查nginx正在运行的是哪个用户,并给予该文件夹适当的权限(你的puppet规则可能授予了错误的权限)

您报告的警告消息是由以下事实触发的:(作为警告状态)“user”指令仅用于当您的nginx主进程以root身份运行时使用。

我知道这已经有一段时间了,但这通常与SELinux有关。 尝试设置为宽容,它可能会正常工作。