阿里雲centos7.x 打開80端口

一 :阿里雲centos7.x用iptables打開80端口

1、安裝iptables:yum install iptables-services(阿里雲centos7 默認 是使用的firewall,所以要使用iptables需先安裝)

2、相看filrwall是否關閉:

                                          查看:systemctl status firewalld

 

                     啓動: systemctl start firewalld

                    關閉: systemctl stop firewalld

                   開機禁用  : systemctl disable firewalld

                   開機啓用  : systemctl enable firewalld

3、把端口加入到iptables中(加入之前,可使用iptables -L -n查看端口情況)

       指令:vim /etc/sysconfig/iptables

       

4、重啓iptables:systemctl restart iptables.service(重啓後,使用 iptables -L -n查看)

 

二:centos7.x用firewall打開80端口

1.關閉與開啓防火牆

      啓動:systemctl start firewalld

      關閉: systemctl stop firewalld

2.查看防火牆是否開啓的狀態,以及開放端口的情況

    systemctl status firewalld.service

    firewall-cmd --list-all 

3. 通過以下命令開放http  80 端口

    firewall-cmd  --add-port=80/tcp --permanent

    命令末尾的--permanent表示用久有效,不加這句的話重啓後剛纔開放的端口就又失效了 

4 .然後重啓防火牆:

    sudo firewall-cmd --reload

5. 再次查看端口的開放情況:

     firewall-cmd --list-all

     ports:裏出現了 80 端口

     

三 OK後,還需在阿里雲控制檯上, 添加安全組規則。

     

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章