Tomcat容器学习笔记
Posted 曾经啊
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Tomcat容器学习笔记相关的知识,希望对你有一定的参考价值。
1.基本概念:
context:在tomcat中相当于一个web 应用。
2.关键目录和文件
- /bin - Startup, shutdown, and other scripts. The
*.sh
files (for Unix systems) are functional duplicates of the*.bat
files (for Windows systems). Since the Win32 command-line lacks certain functionality, there are some additional files in here. 启动停止和其他的脚本。sh文件(unix系统)在功能上和bat文件(windows系统)是重复的。因为win32系统命令行缺少某些功能,这里会有额外的一些文件。 - /conf - Configuration files and related DTDs. The most important file in here is server.xml. It is the main configuration file for the container.
- 配置文件和相关的DTD(document type difinition).最重要的文件是server.xml.它是容器的主要配置文件。
- /logs - Log files are here by default. 默认的日志文件夹。
- /webapps - This is where your webapps go 放置web应用的地方。
3.重要属性:
- CATALINA_HOME: Represents the root of your Tomcat installation, for example
/home/tomcat/apache-tomcat-9.0.10
orC:\\Program Files\\apache-tomcat-9.0.10
. - CATALINA_BASE: Represents the root of a runtime configuration of a specific Tomcat instance. If you want to have multiple Tomcat instances on one machine, use the
CATALINA_BASE
property.
CATALINA_BASE 可以在你想要在一台机器上运行多个tomcat实例时进行设置。
4.tomcat安装配置步骤
1.Download and Install a Java SE Runtime Environment (JRE)
2.Download and Install Apache Tomcat
3.Configure Environment Variables
Tomcat is a Java application and does not use environment variables directly. Environment variables are used by the Tomcat startup scripts. The scripts use the environment variables to prepare the command that starts Tomcat.The Tomcat startup scripts have some logic to set this variable automatically if it is absent, based on the location of the startup script in *nix and on the current directory in Windows. That logic might not work in all circumstances, so setting the variable explicitly is recommended.
tomcat shi一个java应用并不直接使用环境变量。环境变量被tomcat的启动脚本使用。这些脚本用环境变量去准备tomcat启动命令。tomcat启动脚本在这些环境变量不存在时可以自动进行设置,在linux系统里依赖于启动脚本所在的位置,在window系统是当前目录。启动脚本设置环境变量的逻辑可能不适用所有情况,因此推荐显式设置这些变量。
(3.1) Set CATALINA_HOME (required) and CATALINA_BASE (optional) 因为CATALINA_BASE默认和CATALINA_HOME一致。
(3.2) Set JRE_HOME or JAVA_HOME (required)
4.Start Up Tomcat
5.部署启动顺序:
当不使用Tomcat Manager 或者TCD(Tomcat Client Deployer)时tomcat启动顺序如下:
1.Context Descriptors will be deployed first. 应用描述文件会被最先部署。
2.Exploded web applications not referenced by any Context Descriptor will then be deployed. If they have an associated .WAR file in the appBase and it is newer than the exploded web application, the exploded directory will be removed and the webapp will be redeployed from the .WAR
没有关联 应用描述文件的应用文件夹会被部署。如果这些文件夹有关联位于appBase(default appBase is "$CATALINA_BASE/webapps)下的.war文件并且war文件比文件夹下的web应用要新,那么文件夹会被移除,.war文件会被部署。
3.WAR files will be deployed
以上是关于Tomcat容器学习笔记的主要内容,如果未能解决你的问题,请参考以下文章