我很惊讶,因为:
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/