nginx:[emerg] bind()到0.0.0.0:80失败(98:地址已经在使用中),即使在使用端口80终止进程后也是如此

时间:2016-12-23 10:59:47

标签: linux nginx

我正在尝试按如下方式启动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后,我收到完全相同的错误消息。

我使用fuserlsof -inetstat尝试了here描述的其他几种“诊断”:

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工作的任何想法?

1 个答案:

答案 0 :(得分:4)

你应该运行这个

user@user ~ $ sudo netstat -tulpn | grep --color :80

它会显示进程ID

tcp6       0      0 :::80                   :::*                    LISTEN      2063/apache2

2063 / apache2 - PID /进程名称