linux - Nginx 运行与否?

标签 linux service nginx debian

我很惊讶,因为:

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 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:443 failed (98: Address already in use)

当启动 Nginx 时,所以我认为 Nginx 或其他正在端口中运行。我测试过:

lsof -i :80                         
COMMAND   PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
nginx   13557 www-data    8u  IPv4 100729      0t0  TCP *:http (LISTEN)
nginx   13558 www-data    8u  IPv4 100729      0t0  TCP *:http (LISTEN)

是的,Nginx 正在运行,事实上网页正在运行。一切都很完美,但……不是!

这怎么可能?

service nginx status
[FAIL] nginx is not running ... failed!

没有运行?但是我无法启动任何其他实例,因为它正在运行!发生了什么事?

重启时一样:

service nginx restart
Restarting nginx: Enter PEM pass phrase:
Enter PEM pass phrase:
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 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:443 failed (98: Address already in use)

提前致谢。

最佳答案

检查 nginx 是否正在运行:

ps aux | grep nginx

如果 nginx 进程存在,那么它肯定正在运行。你用 lsof 验证的只是证明 80 端口被某个进程占用(例如,apache httpd 或其他一些 http 服务器)。如果 nginx 进程没有运行,但 80 端口正在使用,这也解释了为什么你不能启动你的 nginx。在这种情况下,您需要在进程列表中查找以查看哪个 Web 服务器已经在运行。杀死它并重新启动 nginx,它应该可以正常工作。

关于linux - Nginx 运行与否?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26571382/

相关文章:

linux - 如何在docker中查找FTP主机以及用户名和密码

Android:检测用户何时在联系人列表中选择一个号码(他想打电话)?

java 1.6 TLS1.2 支持使用代理 nginx/squid 解决问题

c - 在c中重新加载linux服务

java - 无法停止/更新处理程序 (removeCallbacksAndMessages)

nginx - kubernetes nginx 入口无法将 HTTP 重定向到 HTTPS

node.js - 如何在 CentOS 上使用 Nginx 反向代理到域子文件夹中的 Node.js 应用程序?

linux - 如何在 Dockerfile 中使用here-strings?

linux - 如何修复 virtualbox 未知文件系统类型 'vbox'

c++ - 错误: ‘size_type’ is not a member of ‘boost::interprocess::message_queue’