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

黄沙百战穿金甲,不破楼兰终不还。这篇文章主要讲述nginx启动的时候报错#yyds干货盘点#相关的知识,希望能为你提供帮助。
问题:

[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

【nginx启动的时候报错#yyds干货盘点#】第三步:修改完之后,进行启动
systemctl restart iptables.service
我们在查看一下端口80 lsof -i:80,把进程号给删掉kill -9 进程号

第四步:再次启动nginx
/usr/local/nginx/sbin/nginx

?第五步:进行访问



    推荐阅读