问题原文
原帖链接 · ironsand · CC BY-SA 3.0
I want to stop Nginx but it fails like this.
$ sudo service nginx stop
Stopping nginx: [FAILED]
And nginx.conf that defines place of nginx.pid have a line.
# /etc/nginx/nginx.conf
pid /var/run/nginx.pid;
But there is no nginx.pid in the directory /var/run/.
locate nginx.pid shows this output.
/var/run/nginx.pid
/var/run/nginx.pid.oldbin
But after updatedb there is no match for the search.
I'm using nginx/1.4.4 in CentOS release 6.5 (Final).
What should I do to stop the nginx daemon?
Edit 2014/01/07
This is output of ps -ef | grep nginx, it seems nginx daemon is still running.
ironsand 17065 16933 0 15:55 pts/0 00:00:00 grep --color nginx
root 19506 1 0 2013 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
ironsand 19507 19506 0 2013 ? 00:00:25 nginx: worker process
And sudo service nginx restart gives this error. I think nginx fails to start because old one still alive. And /var/log/nginx/error.log-2014017 contains also this error.
Stopping nginx: [FAILED]
Starting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
[FAILED]
已采纳解答
原帖链接 · sandeep.s85 · CC BY-SA 3.0
I will recommend stopping nginx by killing it's master process first. The nginx is not shutdown properly may be because of that it can't be stopped using init script.
ps -ef |grep nginx
This will show you the PID of nginx master process. Like you mentioned above:
root 19506 1 0 2013 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
Kill it using
kill -9 19506
Verify once again whether there is any nginx process running or port 80 is occupied. If you see any process is bind to port 80, Identify the PID and check if it can be killed.
ps -ef |grep nginx
netstat -tulpn |grep 80
make sure the filesystem is fine and you can read/write to /var file system. Then Start nginx
service nginx start
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
