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

我用的虚拟机是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有关的进程。据我观察,前四个是Nginx有关的进程,这四个进程要全部杀死,才能启用Nginx。第四个进程是我们抓取Nginx的进程没有关系。

[root@localhost sbin]# ps -ef |grep nginx

www 2479 1 0 12:46 00:00:00 nginx: worker process

www 2480 1 0 12:46 00:00:00 nginx: worker process

www 2483 1 0 12:46 00:00:00 nginx: worker process

www 2485 1 0 12:46 00:00:00 nginx: worker process

root 2491 2405 0 12:47 pts/0 00:00:00 grep nginx

然后我们执行命令:

[root@localhost sbin]# kill -9 2479

[root@localhost sbin]# kill -9 2480

[root@localhost sbin]# kill -9 2483

[root@localhost sbin]# kill -9 2485

查看杀死Nginx1进程后的结果:

[root@localhost sbin]# ps -ef |grep nginx

root 2495 2405 0 12:48 pts/0 00:00:00 grep nginx

这时候我们再次开启Nginx服务:

[root@localhost sbin]# ./nginx

[root@localhost sbin]#

这时候成功了!!!!!!

这个过程中要注意的是:与Nginx有关的进程要全部杀死!!我之前没有全部杀死,导致一直有Nginx进程存在,启用Nginx服务就一直报错。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值