CentOS7上解決tomcat不能被外部瀏覽訪問

原文連接:https://blog.csdn.net/xiaotianice/article/details/78317957linux

 

在linux上開啓的tomcat使用瀏覽器訪問不了。
主要緣由在於防火牆的存在,致使的端口沒法訪問。
CentOS7使用firewall而不是iptables。因此解決這類問題能夠經過添加firewall的端口,使其對咱們須要用的端口開放。
1.使用命令  firewall-cmd --state查看防火牆狀態。獲得結果是running或者not running
2.在running 狀態下,向firewall 添加須要開放的端口
命令爲 firewall-cmd --permanent --zone=public --add-port=8080/tcp //永久的添加該端口。去掉--permanent則表示臨時。
4.firewall-cmd --reload //加載配置,使得修改有效。
5.使用命令 firewall-cmd --permanent --zone=public --list-ports //查看開啓的端口,出現8080/tcp這開啓正確
6.再次使用外部瀏覽器訪問,這出現tomcat的歡迎界面。瀏覽器

補充(CentOS7如下有專門的防火牆操做命令):
開啓防火牆的命令
         systemctl start firewalld.service
關閉防火牆的命令
        systemctl stop firewalld.service
開機自動啓動
        systemctl enable firewalld.service
關閉開機自動啓動
        systemctl disable firewalld.service
查看防火牆狀態
        systemctl status firewalld下列顯示錶示沒有問題
————————————————tomcat

相關文章
相關標籤/搜索