nginx 绑定80端口失败怎么解决?
- 原创
- |
- 浏览: 3771
- |
- 更新:
- |
- 标签: 操作系统
在centos 7上做反向代理,修改conf文件后,重启nginx服务,报Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details,经查阅并实验,得以解决,现在解决方案送上,供大家参考。
方法/步骤
-
使用systemctl status nginx.service -l 查看详情
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
Aug 06 14:08:30 jumpserver systemd[1]: nginx.service: control process exited, code=exited status=1
Aug 06 14:08:30 jumpserver systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
-
从错误中可以看出失败的原因是80端口被占用,所以造成nginx http和反向代理服务没法重启
先使用,ps- ef |grep 80
-
然后找到端口号,使有kill命令杀死进程。
kill -p
重启依然,报出错
-
最后使用fuser命令:
sudo fuser -k 80/tcp
-
因为80端口是专用端口,需要使用sudo命令
fuser命令 识别正在对某个文件或端口访问的进程
-k参数:杀掉访问文件的进程。
-
重启nginx
service nginx reload
nginx http和反向代理服务已经可以正常重启了。
END