debian 8 上 nginx 中的用户 'nginx' 在哪里

Where is user 'nginx' in nginx on debian 8

我在 Debian 7 (wheezy) 上安装了 nginx 1.6.0,现在我想在 Debian 8 (Jessie) 上安装 nginx。这个新 nginx 的版本是 1.6.2。我将旧版本的配置文件nginx.conf复制到新服务器,但是当我尝试启动服务时,它失败了:

service nginx restart

输出:

nginx nginx[10743]: nginx: [emerg] getpwnam("nginx") failed in /etc/nginx/nginx.conf:1

我知道我的问题是 nginx.conf 中的第一行:

user    nginx;

而且我也知道,如果我把这一行改成user www-data,问题就会消失,但为什么会这样呢?我还使用 nginx 作为负载平衡器而不是网络服务器。

$ man getpwnam

The getpwnam() function returns a pointer to a structure containing the broken-out fields of the record in the password database (e.g., the local password file /etc/passwd, NIS, and LDAP) that matches the user‐ name name.

用户nginx不存在。您可以创建它,也可以只使用 www-data 作为用户。