linux 模拟端口占用,虚拟机VM中的Linux启动Nginx时出现80端口被占用的问题解决方法…

  • Post author:
  • Post category:linux


我用的虚拟机是VM,Linux版本是CentOS6.3。在安装完Nginx之后,准备启动Nginx服务。

切到目录:

[root@localhost ~]# cd /usr/local/nginx/sbin

[root@localhost 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()

,Nginx服务使用80端口,看报错信息大概就是80端口已经被占用。

既然80端口已经被占用,那我们就来看看是什么占用了80端口。

[root@localhost ~]# netstat -ntlp|grep 80

tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1468/nginx

看结果,是Nginx进程占用的。那我们就杀死Nginx进程再启动Nginx服务。

首先查看与Nginx有关的进程