本文介绍了重新启动nginx:nginxnginx:[emerg] bind()到0.0.0.0:80失败(98:地址已在使用中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用sudo/etc/init.d/nginx restart重新启动nginx时,我收到了来自主题的消息.

When I try to restart nginx with sudo /etc/init.d/nginx restart I get the message from the subject.

我发现原因很可能是脚本不知道如何停止守护进程,因为在启动时未创建pid文件(/var/run/nginx.pid).

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.

我在两个不同的服务器上有两个安装...一个是从源代码编译的,另一个是通过phusion来的.

I have two installations on two different servers... one was compiled from source and the other came with phusion passenger.

我尝试了以下命令:

start-stop-daemon --start --quiet --pidfile /var/run/nginx.pid --exec /usr/sbin/nginx -- -c /etc/nginx/nginx.conf

在两台计算机上都创建了一个pid文件,而在另一台计算机上却没有-那个文件上的路径有些不同(但我认为这并不重要):

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):

start-stop-daemon --start --quiet --pidfile /var/run/nginx.pid --exec /opt/nginx/sbin/nginx -- -c /opt/nginx/conf/nginx.conf

该过程开始且未写入pid ...

The process starts and pid is not written...

我正在使用Debian ...

I'm on Debian...

有什么建议吗?

推荐答案

解决方案是在nginx.conf中取消注释此行:

The solution is to uncomment this line in nginx.conf:

pid        /var/run/nginx.pid;

看起来不同的安装方式会有所不同,但是正确的做法是取消注释.

It looks like different installations do it differently but the right thing is to uncomment it.

这篇关于重新启动nginx:nginxnginx:[emerg] bind()到0.0.0.0:80失败(98:地址已在使用中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 04:55