nginx用户权限

我最近从Apache2切换到nginx

我已经安装了一切,当我sudo nginx -t它说,一切都很好。

但是当我只是做nginx -t我得到以下错误:

 nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied) 2012/10/24 12:22:16 [warn] 23075#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1 2012/10/24 12:22:16 [emerg] 23075#0: SSL_CTX_use_PrivateKey_file("/etc/ssl/private/myapp.key") failed (SSL: error:0200100D:system library:fopen:Permission denied error:20074002:BIO routines:FILE_CTRL:system lib error:140B0002:SSL routines:SSL_CTX_use_PrivateKey_file:system lib) 

分别以下似乎也没有任何错误重新启动:

 sudo service nginx reload sudo service nginx restart sudo service php5-fpm restart 

这是预期的吗?

是的,如果将nginx -t作为非特权用户运行,则可以预料。 使用sudo(8)运行命令时,以root用户身份运行这些命令,您将可以打开日志文件,而这些日志文件您个人用户似乎不具备。

nginx -t应该像你从nginx开始一样运行,获得正确的结果。