我尝试按如下方式启动 nginx:
kurt@kurt-ThinkPad:~$ which nginx
/usr/sbin/nginx
kurt@kurt-ThinkPad:~$ sudo /usr/sbin/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()
关注此EasyEngine tutorial ,我试图通过 fuser -k
终止使用端口 80 的进程:
kurt@kurt-ThinkPad:~$ sudo fuser -k 80/tcp
80/tcp: 31924 31925 31926
但是,在重新运行 sudo/usr/sbin/nginx
之后,我得到了完全相同的错误消息。
我已经尝试了描述的其他几个“诊断”here ,使用 fuser
、lsof -i
和 netstat
:
kurt@kurt-ThinkPad:~$ fuser 80/tcp
kurt@kurt-ThinkPad:~$ lsof -i :80 | grep LISTEN
kurt@kurt-ThinkPad:~$ netstat -tulpn | grep --color :80
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:8060 0.0.0.0:* LISTEN -
只有 netstat
命令给出了结果,但我无法从中推断出进程 ID。
关于如何让 nginx 工作的任何想法?
最佳答案
你应该运行这个
user@user ~ $ sudo netstat -tulpn | grep --color :80
它会显示你的进程号
tcp6 0 0 :::80 :::* LISTEN 2063/apache2
2063/apache2 – PID/进程名称
关于linux - nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) 即使在使用端口 80 终止进程之后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41300133/