Tag Archives: Mistakes and Summaries

Error! Failed to start nginx

The following error occurred when the blogger started the Nginx service

[root@localhost ~]# /usr/local/nginx/sbin/nginx 
nginx: [emerg] getpwnam("nginx") failed

The function of getPwnam in the error message is to get information about the user’s login
So you can see that getting “nginx” users failed
Query the user with id, and sure enough, it does not exist

[root@localhost ~]# id nginx
id: nginx: no such user

Once the user is added, it works

[root@localhost ~]# useradd -M -s /sbin/nologin nginx
[root@localhost ~]# /usr/local/nginx/sbin/nginx
[root@localhost ~]# netstat -anpt | grep nginx
tcp        0      0 10.0.0.100:80           0.0.0.0:*               LISTEN      3843/nginx: master  

Recall that the configuration for source code compilation and installation was as follows

./configure --prefix=/usr/local/nginx --user=nginx --group=nginx && make && make install 

At that time, the user group and user group of Nginx were set. In the absence of nginx users in the system, it could not be started naturally.