0
点赞
收藏
分享

微信扫一扫

nginx启动的时候报错#yyds干货盘点#

诗远 2022-02-13 阅读 69

问题:

[root@localhost nginx-1.14.2]# /usr/local/nginx/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()

​遇到这种情况,我们首先得知道,他是因为端口被占用了


第一步:如果我们有iptables,我们就跳过这一步,如果没有则安装​

yum -y install iptables-services
systemctl mask firewalld.service
systemctl enable iptables.services
systemctl enable ip6tables.services

第二步:修改iptables配置文件

vim /etc/sysconfig/iptables添加我们所需要放行的端口
-A INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT

第三步:修改完之后,进行启动

systemctl restart iptables.service
我们在查看一下端口80 lsof -i:80,把进程号给删掉kill -9 进程号

第四步:再次启动nginx

/usr/local/nginx/sbin/nginx

​第五步:进行访问


举报

相关推荐

0 条评论