我试图运行nginx作为当前用户(= ayush)。 但是在设置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
我的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; } } }
也:
ayush@manjaro ~> whoami ayush
user指令有两个参数,您的用户和您的组名称。 如果您不指定组名称,则认为它与您的用户名相同。
错误是因为组名ayush不存在。
详情请参阅此文件 。
您需要为user指令,用户和组名指定两个参数。 如果没有组名,如果指定,它会认为它与用户相同,这似乎是在你的情况下,即你的组名与用户(ayush)不一样的问题。
要查看您的用户名,请执行以下命令:
whoami
要查看您的组名称,请执行以下命令:
id -g -n $whoami
在MacOS组名称是一个数字(使用命令:id -g -n $ whoami或打开MacOS设置 – >用户和组 – >右键单击您的帐户,然后select高级选项)。 但是,如果我将组名称指定为“员工”,则nginx才有效。
我的nginxconfiguration:
用户MyUserName的工作人员; …