1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
| 重启vultr服务器之后,ghost博客会出现无法打开的问题,查看nginx,然后在网页输入服务器的ip地址,也不会出现任何nginx页面,所以能够确定是nginx服务器出错,然后去查看nginx,发现端口已经被占用,以下给出一系列操作命令:
yum install iptables-services
systemctl mask firewalld.service
systemctl enable iptables.service
systemctl enable ip6tables.service
vi /etc/sysconfig/iptables
进入编辑状态: *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [6:696] -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT -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 -A INPUT -p tcp -m state --state NEW -m tcp --dport 30000:30999 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT
退出并保存,
重启iptables
systemctl restart iptables.service
开启防火墙
systemctl start firewalld
开启http
firewall-cmd --permanent --add-service=http
开启nginx的 80 端口
firewall-cmd --permanent --zone=trusted --add-port=80/tcp
然后输入命令nginx,如果输出以下信息
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use
则表示你的nginx已经被占用
使用以下命令杀死
killall -9 nginx
再次查看nginx状态
ps aux|grep nginx
你会发现只有一个,就正常了
然后重启nginx
sudo systemctl restart nginx
再次在网页输入服务器ip地址,则可以正常打开
如果还需要配置https,记住要开放443端口,用以下的命令
[root@vultr nginx]# firewall-cmd --zone=public --add-port=443/tcp
Warning: ALREADY_ENABLED: '443:tcp' already in 'public'
success
[root@vultr nginx]# firewall-cmd --zone=public --add-port=443/tcp --permanent
success
|