虚拟机VM中的Linux启动Nginx时出现80端口被占使用

作者 : 开心源码 本文共1351个字,预计阅读时间需要4分钟 发布时间: 2022-05-12 共242人阅读

我使用的虚拟机是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服务就一直报错。

说明
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是摆设,本站源码仅提供给会员学习使用!
7. 如遇到加密压缩包,请使用360解压,如遇到无法解压的请联系管理员
开心源码网 » 虚拟机VM中的Linux启动Nginx时出现80端口被占使用

发表回复