Nginx启动时出现Address already in use 解决方案

来源:互联网 发布:java中命令行是什么 编辑:程序博客网 时间:2024/06/02 06:37

启动Ngnix的时候提示错误,异常信息如下。

[root@centos-512mb-sfo2-01 nginx-1.10.3]# /opt/nginx-1.10.3/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()

问题描述:端口已被使用,导致端口占用,出现此错误。
解决方案:
1. 查看当前端口的使用情况
原因: 端口 80 端口被占用,用 “lsof -i:80” 命令查看一下是什么程序占用了80端口,我的结果显示是 80 端口被 Apache 占用

[root@centos-512mb-sfo2-01 nginx-1.10.3]# lsof -i:80COMMAND   PID   USER   FD   TYPE  DEVICE SIZE/OFF NODE NAMEhttpd    5304 apache    4u  IPv6 4955869      0t0  TCP *:http (LISTEN)httpd   13021 apache    4u  IPv6 4955869      0t0  TCP *:http (LISTEN)httpd   13022 apache    4u  IPv6 4955869      0t0  TCP *:http (LISTEN)httpd   13023 apache    4u  IPv6 4955869      0t0  TCP *:http (LISTEN)httpd   13025 apache    4u  IPv6 4955869      0t0  TCP *:http (LISTEN)httpd   16084 apache    4u  IPv6 4955869      0t0  TCP *:http (LISTEN)httpd   16085 apache    4u  IPv6 4955869      0t0  TCP *:http (LISTEN)httpd   16086 apache    4u  IPv6 4955869      0t0  TCP *:http (LISTEN)httpd   19021   root    4u  IPv6 4955869      0t0  TCP *:http (LISTEN)httpd   21515 apache    4u  IPv6 4955869      0t0  TCP *:http (LISTEN)httpd   21517 apache    4u  IPv6 4955869      0t0  TCP *:http (LISTEN)

既然被占用,就将占用的进程关闭即可.像上面的问题我们可以采用:

        service httpd stop

关闭Apache进程即可.
同理,要是在安装了nginx的服务器要想启动Apache,关闭nginx进程即可.

阅读全文
0 0
原创粉丝点击