Nginx daemon stop is failing
sudo service nginx restart
will give you something like this:
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()
then kill the process manually by their port:
sudo fuser -k 80/tcp
(or use whatever port you are using)
alternatively, kill the processes by their ID:
ps -ef |grep nginx
kill <pid>
It's likely that it can't kill the process.
Open up the nginx sysvinit script located in /etc/init.d/ (or /etc/rc.d/) and find where nginx.pid is thought to be. It'll be something like "/var/run/nginx.pid".
If the pid file isn't there, open nginx.conf and look for the pid setting. If it is a mismatch - set the conf value to where the script thinks it should be, e.g.
# pid of nginx process
pid /var/run/nginx.pid;
I had faced similar issues.
Generally I use apache/apache2.
The following might help you:
sudo nginx -s stop | ps -ef | grep nginx | awk {'print $2'} | xargs sudo kill -9 | sudo service apache2 start
For docs please refer this Github Gist
try this command:
sudo fuser -k 80/tcp