歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> CentOS開放80、8080端口或者開放某個端口

CentOS開放80、8080端口或者開放某個端口

日期:2017/3/3 17:01:30   编辑:關於Linux

裝載系統的時候只開啟了22端口。結果再裝完Nginx+php+mysql 後不能訪問網站。

  iptables -L -n

  查看防火牆設置發現沒開啟80端口

  由於Linux防火牆默認是關閉的。可以用兩種方式,一個是關閉防火牆,另一個就是讓防火牆開放這個端口。

  關閉防火牆命名:

  service iptables stop (不推薦)

  開放8080端口的解決步驟如下:

  1、修改/etc/sysconfig/iptables 文件,增加如下一行:

  -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT

  重啟iptables

  service iptables restart

  2、重啟防火牆,這裡有兩種方式重啟防火牆

  a) 重啟後生效

  開啟: chkconfig iptables on

  關閉: chkconfig iptables off

  b) 即時生效,重啟後失效

  開啟: service iptables start

  關閉: service iptables stop

  開放一個范圍的端口3000到5000

  -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3000:5000 -j ACCEPT

Copyright © Linux教程網 All Rights Reserved