getgrnam("user") 在 /etc/nginx/nginx.conf 中失败

Ayu*_*ush 11 nginx user-permissions

我正在尝试以当前用户(=ayush)的身份运行 nginx。但是在设置user指令时出现以下错误:

Dec 11 22:26:13 manjaro nginx[17194]: 2015/12/11 22:26:13 [emerg] 17194#0: getgrnam("ayush") failed in /etc/nginx/nginx.conf:1
Dec 11 22:26:13 manjaro systemd[1]: nginx.service: Control process exited, code=exited status=1
Run Code Online (Sandbox Code Playgroud)

我的 nginx.conf :

user ayush;
worker_processes 1;

error_log  /var/log/nginx/error.log;
events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #access_log  logs/access.log  main;

    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;


        location / {
            root   /code/server;
            autoindex on;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

还:

ayush@manjaro ~> whoami
ayush
Run Code Online (Sandbox Code Playgroud)

Ric*_*ith 18

user指令采用两个参数,您的用户和您的组名。如果您不指定组名,则假定它与您的用户名相同。

错误是因为组名ayush不存在。

有关详细信息,请参阅此文档


big*_*gvn 7

在 MacOS 中,组名是一个数字(使用命令:id -g -n $whoami 或打开 MacOS 设置 -> 用户和组 -> 右键单击​​您的帐户并选择高级选项)。但是 nginx 只有在我将组名指定为“员工”时才有效。

我的 nginx 配置:

用户 MyUserName 员工;...