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

在linux上開啓的tomcat使用瀏覽器訪問不了。linux

主要緣由在於防火牆的存在,致使的端口沒法訪問。瀏覽器

CentOS7使用firewall而不是iptables。因此解決這類問題能夠經過添加firewall的端口,使其對咱們須要用的端口開放。tomcat

1.使用命令  firewall-cmd --state查看防火牆狀態。獲得結果是running或者not runningtcp

2.在running 狀態下,向firewall 添加須要開放的端口ip

命令爲 firewall-cmd --permanent --zone=public --add-port=8080/tcp //永久的添加該端口。去掉--permanent則表示臨時。cmd

4.firewall-cmd --reload //加載配置,使得修改有效。table

5.使用命令 firewall-cmd --permanent --zone=public --list-ports //查看開啓的端口,出現8080/tcp這開啓正確配置

6.再次使用外部瀏覽器訪問,這出現tomcat的歡迎界面。iptables

 

補充:service

開啓防火牆的命令

         systemctl start firewalld.service

關閉防火牆的命令

        systemctl stop firewalld.service

開機自動啓動

        systemctl enable firewalld.service

關閉開機自動啓動

        systemctl disable firewalld.service

查看防火牆狀態

        systemctl status firewalld下列顯示錶示沒有問題。

相關文章
相關標籤/搜索