Centos7 yum安装tomcat

系统环境

[root@ecs-19cb ~]# cat /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core) 

 

[root@ecs-19cb etc]# ip add
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether fa:16:3e:0d:49:d3 brd ff:ff:ff:ff:ff:ff
    inet 192.168.2.9/24 brd 192.168.2.255 scope global dynamic eth0
       valid_lft 75865sec preferred_lft 75865sec
    inet6 fe80::f816:3eff:fe0d:49d3/64 scope link 
       valid_lft forever preferred_lft forever

一、搭建准备:

1、先到tomcat官网https://tomcat.apache.org/查看下载路径

Centos7 yum安装tomcat_第1张图片
Centos7 yum安装tomcat_第2张图片

Centos7 yum安装tomcat_第3张图片

2、安装wget

[root@ecs-19cb ~]# yum install -y wget

3、确认是否安装成功

[root@ecs-19cb ~]# rpm -qa | grep wget
wget-1.14-15.el7_4.1.x86_64

4、wget下载

[root@ecs-19cb ~]# wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-9/v9.0.4/bin/apache-tomcat-9.0.4.tar.gz
[root@ecs-19cb ~]# ll
total 9272
-rw-r--r--  1 root root 9471519 Jan 19 04:03 apache-tomcat-9.0.4.tar.gz

5、选择yum安装tomcat需要的jdk,就不用再手动配置环境变量。

[root@ecs-19cb ~]# yum -y install java-1.8*

6、查看版本

[root@ecs-19cb ~]# java -version
openjdk version "1.8.0_161"
OpenJDK Runtime Environment (build 1.8.0_161-b14)
OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode)

二、解压并启动:

1、解压

[root@ecs-19cb ~]# tar -zxvf apache-tomcat-9.0.4.tar.gz 
[root@ecs-19cb ~]# ll
total 9276
drwxr-xr-x  9 root root    4096 Feb  3 13:59 apache-tomcat-9.0.4
-rw-r--r--  1 root root 9471519 Jan 19 04:03 apache-tomcat-9.0.4.tar.gz

2、启动tomcat,显示tomcat started就是成功启动

[root@ecs-19cb ~]# ll
total 9276
drwxr-xr-x  9 root root    4096 Feb  3 13:59 apache-tomcat-9.0.4
-rw-r--r--  1 root root 9471519 Jan 19 04:03 apache-tomcat-9.0.4.tar.gz
[root@ecs-19cb ~]# cd apache-tomcat-9.0.4/
[root@ecs-19cb apache-tomcat-9.0.4]# ./bin/startup.sh 
Using CATALINA_BASE:   /root/apache-tomcat-9.0.4
Using CATALINA_HOME:   /root/apache-tomcat-9.0.4
Using CATALINA_TMPDIR: /root/apache-tomcat-9.0.4/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /root/apache-tomcat-9.0.4/bin/bootstrap.jar:/root/apache-tomcat-9.0.4/bin/tomcat-juli.jar
Tomcat started.

3、关闭防火墙

[root@ecs-19cb etc]# systemctl stop firewalld
[root@ecs-19cb etc]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

4、查看tomcat默认端口8080是否开启

[root@ecs-19cb ~]# netstat -ntlp
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:111             0.0.0.0:*               LISTEN      1/systemd           
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1528/sshd           
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1123/master         
tcp        0      0 127.0.0.1:32001         0.0.0.0:*               LISTEN      1541/java           
tcp6       0      0 :::8009                 :::*                    LISTEN      11809/java          
tcp6       0      0 :::111                  :::*                    LISTEN      1/systemd           
tcp6       0      0 :::8080                 :::*                    LISTEN      11809/java          
tcp6       0      0 :::22                   :::*                    LISTEN      1528/sshd           
tcp6       0      0 ::1:25                  :::*                    LISTEN      1123/master         
tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN      11809/java   

三、浏览器打开:http://192.168.2.9:8080

Centos7 yum安装tomcat_第4张图片

 

你可能感兴趣的:(Linux)