环境准备
由于是在练习,为了方便,我们可以
1.关闭防火墙
systemctl disable firewalld.service
systemctl stop firewalld.service
2.关闭selinux
在/etc/selinux/config中,设置:
SELINUX=disabled
3.准备jdk---》jdk-8u333-linux-x64.tar.gz这个包
可以在编程宝库下载:http://www.codebaoku.com/jdk/jdk-oracle-jdk1-8.html#jdk8u333
创建目录:
mkdir -p /usr/java/
解压:
tar xf jdk-8u333-linux-x64.tar.gz -C /usr/java/
配置:
vim /etc/profile.d/java.sh
JAVA_HOME=/usr/java/jdk1.8.0_333
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME CLASSPATH PATH
测试
source /etc/profile.d/java.sh
java -version
4.准备apache-tomcat-8.5.70.tar.gz这个包
解压到 /usr/local:
[root@localhost ~]# tar xf apache-tomcat-8.5.70.tar.gz -C /usr/local/
创建软链接
[root@localhost ~]# ln -s /usr/local/apache-tomcat-8.5.70 /usr/local/tomcat编写配置:
echo 'export TOMCAT_HOME=/usr/local/tomcat'>>/etc/profile.d/tomcat.sh
检查:
[root@localhost ~]# source /etc/profile.d/tomcat.sh[root@localhost ~]# /usr/local/tomcat/bin/version.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1.8.0_333
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Server version: Apache Tomcat/8.5.70
Server built: Aug 9 2021 16:17:14 UTC
Server number: 8.5.70.0
OS Name: Linux
OS Version: 3.10.0-514.el7.x86_64
Architecture: amd64
JVM Version: 1.8.0_333-b02
JVM Vendor: Oracle Corporation
运行:
在/usr/local/apache-tomcat-8.5.70/bin 目录下
[root@localhost bin]# ./startup.sh
Using CATALINA_BASE: /usr/local/apache-tomcat-8.5.70
Using CATALINA_HOME: /usr/local/apache-tomcat-8.5.70
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-8.5.70/temp
Using JRE_HOME: /usr/java/jdk1.8.0_333
Using CLASSPATH: /usr/local/apache-tomcat-8.5.70/bin/bootstrap.jar:/usr/local/apache-tomcat-8.5.70/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Tomcat started.
5.测试:
6.目录结构介绍
[root@localhost tomcat]# tree -L 1
.[root@localhost ~]# cd /usr/local/tomcat/ [root@localhost tomcat]# tree -L 1 .├── bin #存放tomcat管理脚本
├── conf # tomcat 配置文件存放目录
├── lib # web应用调用的jar包存放路径
├── LICENSE Tomcat配置文件目录介绍 2.4 Tomcat管理 Tomcat启动停止 为tomcat提供服务启动脚本。 启动后访问页面: image-20210220164641358
├── logs # tomcat 日志存放目录,catalina.out 为主要输出日志
├── NOTICE
├── RELEASE-NOTES
├── RUNNING.txt
├── temp # 存放临时文件
├── webapps # web程序存放目录
└── work # 存放编译产生的.java 与 .class文件 7 directories, 4 files
[root@localhost ~]# cd /usr/local/tomcat/webapps
[root@localhost webapps]# tree -L 1 .
├── docs # tomcat 帮助文档
├── examples # web应用实例
├── host-manager # 主机管理
├── manager # 管理
└── ROOT # 默认站点根目录
root@localhost ~]# cd /usr/local/tomcat/conf
[root@localhost conf]# tree -L 1 .
├── Catalina
├── catalina.policy
├── catalina.properties
├── context.xml
├── logging.properties
├── logs
├── server.xml # tomcat 主配置文件
├── server.xml.bak
├── server.xml.bak2
├── tomcat-users.xml # tomcat 管理用户配置文件
├── tomcat-users.xsd
└── web.xml 2 directories, 10 files