1.Tomcat运行环境JDK
JDK下载面页:
2.安装Tomcat & JDK
关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
3.安装JDK
tar xzf jdk-8u191-linux-x64.tar.gz -C /usr/local/
cd /usr/local/
mv jdk1.8.0_191/ java
配置环境变量
vim /etc/profile.d/jdk.sh
#指定java安装目录
export JAVA_HOME=/usr/local/java
#用于指定java系统查找命令的路径
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
#类的路径,在编译运行java程序时,如果有调用到其他类的时候,在classpath中寻找需要的类。
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar
检测JDK是否安装成功
source /etc/profile.d/jdk.sh
java -version
成功显示
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
4.安装Tomcat
wget https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.49/bin/apache-tomcat-8.5.49.tar.gz
tar xzf apache-tomcat-8.5.49.tar.gz -C /usr/local/
cd /usr/local/
mv apache-tomcat-8.5.49/ tomcat
配置环境
vim /etc/profile
#指定tomcat的安装目录
export TOMCAT_HOME=/data/application/tomcat
#在jdk环境变量、PATH变量后添加:$TOMCAT_HOME/bin
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$TOMCAT_HOME/bin
source /etc/profile
查看tomcat是否安装成功:
/usr/local/tomcat/bin/version.sh
成功显示
Using CATALINA_BASE: /data/application/tomcat
Using CATALINA_HOME: /data/application/tomcat
Using CATALINA_TMPDIR: /data/application/tomcat/temp
Using JRE_HOME: /usr/local/jdk
Using CLASSPATH: /data/application/tomcat/bin/bootstrap.jar:/data/application/tomcat/bin/tomcat-juli.jar
Server version: Apache Tomcat/8.5.49
Server built: Nov 17 2019 18:45:30 UTC
Server number: 8.5.49.0
OS Name: Linux
OS Version: 3.10.0-514.el7.x86_64
Architecture: amd64
JVM Version: 1.8.0_211-b12
JVM Vendor: Oracle Corporation
5.Tomcat的管理
启动程序 #/usr/local/tomcat/bin/startup.sh #启动
关闭程序 #/usr/local/tomcat/bin/shutdown.sh #关闭
检查tomcat是否启动正常
netstat -lntp |grep java
tcp6 0 0 :::8080 :::* LISTEN 30560/java
tcp6 0 0 127.0.0.1:8005 :::* LISTEN 30560/java
tcp6 0 0 :::8009 :::* LISTEN 30560/java