centos 安装 tomcat8.5

1.下载

下载地址:https://tomcat.apache.org/download-80.cgi

[root@centos7 ~]# wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-8/v8.5.34/bin/apache-tomcat-8.5.34.tar.gz

[root@centos7 ~]# tar -zxvf apache-tomcat-8.5.34.tar.gz

[root@centos7 ~]# mv apache-tomcat-8.5.34 /usr/tomcat8.5

2.启动

进入/usr/tomcat8.5/bin 目录

启动

[root@centos7 ~]# ./startup.sh

查看是否启动成功(8080 已经启动成功)

[root@centos7 ~]# netstat -nltp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      1632/mysqld         
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1000/sshd           
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1118/master         
tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN      11118/java          
tcp6       0      0 :::8009                 :::*                    LISTEN      11118/java          
tcp6       0      0 :::8080                 :::*                    LISTEN      11118/java          
tcp6       0      0 :::22                   :::*                    LISTEN      1000/sshd           
tcp6       0      0 ::1:25                  :::*                    LISTEN      1118/master

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

 

 

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值