Nginx没有运行。 没有得到任何错误

如果我运行:

$ sudo service nginx status * nginx is not running 

然后我运行:

 $ sudo service nginx start 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] still could not bind() 

所以我杀了它:

 sudo fuser -k 80/tcp 

所以我尝试再次启动Nginx:

 $ sudo service nginx start Starting nginx: nginx. 

应该现在跑吧?

 $ sudo service nginx status * nginx is not running 

我试过了:

 $ ps aux | grep nginx root 1316 0.0 0.2 64988 1236 ? Ss 14:37 0:00 nginx: master process /usr/sbin/nginx nobody 1317 0.0 0.3 65408 1908 ? S 14:37 0:00 nginx: worker process myusername 1436 0.0 0.1 9388 876 pts/2 S+ 14:40 0:00 grep nginx 

当我访问该网站的IP。 我在底部得到一个带有nginx/1.2.1的404消息。 在我看来,它实际上在运行。 而我阻止在nginx.conf中的IP地址,这些IP目前被阻止,我testing。 所以我很困惑Nginx是否在运行,以及如何把握这个野兽。
我的最终目标是让Gunicorn也运行。 奇怪的是,这一切都在昨天工作。 Gunicorn和Nginx都具有working状态。

404 =找不到页面。

这意味着nginx正在服务请求(沿着你没有任何其他的80端口上运行)。 从它的声音,服务器已经开始罚款。 只需在你的nginx目录的根目录下用“hello world”创build一个index.htm文件,你就会看到一些东西。

也许你在同一个端口上运行apache,而nginx不能绑定这个地址,因为它已经在使用了。
要改变nginx的端口,看看这个回复在stackoverflow [1] https://stackoverflow.com/questions/10829402/how-to-start-nginx-via-different-portother-than-80

这里有一个例子,我的哈巴狗

 marco@BeastFMM:~$ sudo service nginx start 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() nginx. marco@BeastFMM:~$ sudo /etc/init.d/apache2 stop sudo: unable to resolve host BeastFMM * Stopping web server apache2 apache2: apr_sockaddr_info_get() failed for BeastFMM apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName ... waiting [ OK ] marco@BeastFMM:~$ sudo service nginx start Starting nginx: nginx. marco@BeastFMM:~$ ps aux | grep nginx root 7986 0.0 0.0 78976 1288 ? Ss 17:07 0:00 nginx: master process /usr/sbin/nginx www-data 7987 0.0 0.0 79316 1708 ? S 17:07 0:00 nginx: worker process www-data 7988 0.0 0.0 79316 1708 ? S 17:07 0:00 nginx: worker process www-data 7989 0.0 0.0 79316 1708 ? S 17:07 0:00 nginx: worker process www-data 7990 0.0 0.0 79316 1708 ? S 17:07 0:00 nginx: worker process 

你改变了pid文件的位置吗? 通常,当你启动一个服务时,它会检查它是否已经运行,如果是则不做任何事情,否则不启动。 所以那些绑定错误你不应该发生。

使用vinit的默认位置vor nginx pid文件是/var/run/nginx.pid。