[英]Restarting nginx: nginxnginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
When I try to restart nginx with sudo /etc/init.d/nginx restart I get the message from the subject. 当我尝试使用sudo /etc/init.d/nginx restart重新启动nginx时,我收到了来自主题的消息。
I discovered that the reason is most likely that the script doesn't know how to stop the deamon because the pid file (/var/run/nginx.pid) is not created on start. 我发现原因很可能是脚本不知道如何停止守护程序,因为pid文件(/var/run/nginx.pid)不是在启动时创建的。
I have two installations on two different servers... one was compiled from source and the other came with phusion passenger. 我在两个不同的服务器上安装了两个...一个是从源代码编译的,另一个是由phusion乘客编写的。
I tried this command: 我试过这个命令:
start-stop-daemon --start --quiet --pidfile /var/run/nginx.pid --exec /usr/sbin/nginx -- -c /etc/nginx/nginx.conf
on both machines and on one the pid file is created and on the other it is not - on that machine the paths are a bit different (but I don't think this is relevant): 在两台机器上和一台机器上创建了pid文件而在另一台机器上它不是 - 在那台机器上路径有点不同(但我不认为这是相关的):
start-stop-daemon --start --quiet --pidfile /var/run/nginx.pid --exec /opt/nginx/sbin/nginx -- -c /opt/nginx/conf/nginx.conf
The process starts and pid is not written... 流程开始,pid没有写...
I'm on Debian... 我在Debian上...
Any suggestions? 有什么建议?
The solution is to uncomment this line in nginx.conf: 解决方案是在nginx.conf中取消注释这一行:
pid /var/run/nginx.pid;
It looks like different installations do it differently but the right thing is to uncomment it. 看起来不同的安装方式不同,但正确的方法是取消注释。
I was able to fix this by running the following fuser command 我能够通过运行以下fuser命令来解决这个问题
$ sudo fuser -k 80/tcp $ sudo fuser -k 80 / tcp
which kills whatever process is using port 80..hopefully didn't screw anything else. 这会杀死使用端口80的任何进程。但是他没有搞任何其他东西。
Credit for this goes to: https://goo.gl/6oc0xD 这归功于: https : //goo.gl/6oc0xD
$ sudo nginx -t
要查看所有进程,有时您没有完全权限
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.