Tomcat介绍

Tomcat介绍及安装_第1张图片

安装jdk

Tomcat介绍及安装_第2张图片

1.下载jdk包,并放到、usr/local/src目录下:

[root@weix-01 src]# ls
httpd-2.2.34         httpd-2.4.29.tar.gz
httpd-2.2.34.tar.gz  jdk-8u161-linux-x64.tar.gz
httpd-2.4.29         mysql-5.6.36-linux-glibc2.5-x86_64.tar.g

2.进行解压:

[root@weix-01 src]# tar zxvf jdk-8u161-linux-x64.tar.gz

3.移动位置并改名:

[root@weix-01 src]# mv jdk1.8.0_161/ /usr/local/jdk1.8

4.编辑环境变量配置文件:

[root@weix-01 src]# vim /etc/profile
JAVA_HOME=/usr/local/jdk1.8/
JAVA_BIN=/usr/local/jdk1.8/bin
JRE_HOME=/usr/local/jdk1.8/jre
PATH=$PATH:/usr/local/jdk1.8/bin:/usr/local/jdk1.8/jre/bin
CLASSPATH=/usr/local/jdk1.8/jre/lib:/usr/local/jdk1.8/lib:/usr/local/jdk1.8/jre/
lib/charsets.jar

5.重置让变量生效:

[root@weix-01 src]# source /etc/profile

6.测试是否安装成功:

[root@weix-01 src]# java -version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

安装Tomcat

Tomcat介绍及安装_第3张图片

1.下载安装包:

[root@weix-01 src]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.29/bin/apache-tomcat-8.5.29.tar.gz

2.解压缩:

[root@weix-01 src]# tar zxvf apache-tomcat-8.5.29.tar.gz

3.移动位置:

[root@weix-01 src]# mv apache-tomcat-8.5.29 /usr/local/tomcat

4.启动服务:

[root@weix-01 src]# /usr/local/tomcat/bin/startup.sh
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr/local/jdk1.8
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.

5.检查进程:

[root@weix-01 src]# ps aux |grep java
root       1388 17.9  8.3 2294712 83400 pts/0   Sl   16:53   0:04 /usr/local/jdk1.8/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dignore.endorsed.dirs= -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start
root       1432  0.0  0.0 112676   980 pts/0    R+   16:53   0:00 grep --color=auto java

6.关闭服务:不支持restart,要关闭再启动

[root@weix-01 src]# /usr/local/tomcat/bin/shutdown.sh
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr/local/jdk1.8
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

7.查看端口:8080,为web服务提供端口,8005为管理端口,8009为第三方调用端口

[root@weix-01 src]# netstat -lntp |grep java
tcp6       0      0 :::8080                 :::*                    LISTEN         1475/java
tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN         1475/java
tcp6       0      0 :::8009                 :::*                    LISTEN         1475/java