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下列显示表示没有问题。

相关文章
相关标签/搜索