1.Introduction - 介绍
For administrators and web developers alike, there are some important bits of information you should familiarize yourself with before starting out. This document serves as a brief introduction to some of the concepts and terminology behind the Tomcat container. As well, where to go when you need help.
对于管理员和Web开发人员来说,在开始之前,您应该熟悉一些重要的信息。本文档简要介绍了Tomcat容器背后的一些概念和术语。同样的,当你需要帮助时告诉你去哪里找答案。
2.Terminology - 术语
In the course of reading these documents, you will run across a number of terms; some specific to Tomcat, and others defined by the .
在阅读这些文件的过程中,您将遇到许多术语; 一些特定于Tomcat的,以及其他由定义的 。
- Context - In a nutshell, a Context is a web application.
- 上下文 - 简而言之,Context是一个Web应用程序。
That is it. If you find any more terms we need to add to this section, please do let us know.
上述这些,如果您发现我们需要在此部分添加更多字词,请告知我们。
3.Directories and Files - 目录和文件
These are some of the key tomcat directories:
这些是一些关键的tomcat目录:
- /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. - / bin - 启动,关闭和其他脚本。这些 *.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.
- / conf - 配置文件和相关的 DTD。这里最重要的文件是 server.xml。它是容器的主要配置文件。
- /logs - Log files are here by default.
- / logs - 默认情况下,日志文件在此处。
- /webapps - This is where your webapps go.
- / webapps - 这是您的 webapps 存放的地方。
4.CATALINA_HOME and CATALINA_BASE
Throughout the documentation, there are references to the two following properties:
在整个文档中,引用了以下两个属性:
-
CATALINA_HOME: Represents the root of your Tomcat installation, for example /home/tomcat/apache-tomcat-9.0.10 or C:\Program Files\apache-tomcat-9.0.10.
-
CATALINA_HOME:表示 Tomcat 安装的根目录,例如/home/tomcat/apache-tomcat-9.0.10 或C:\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 实例的运行时配置的根。如果要在一台计算机上拥有多个 Tomcat 实例,请使用该 CATALINA_BASE 属性。
If you set the properties to different locations, the CATALINA_HOME location contains static sources, such as .jar files, or binary files. The CATALINA_BASE location contains configuration files, log files, deployed applications, and other runtime requirements.
如果将属性设置为其他位置,则 CATALINA_HOME 位置包含静态源,例如.jar 文件或二进制文件。CATALINA_BASE 位置包含配置文件,日志文件,已部署的应用程序和其他运行时要求。
4.1.Why Use CATALINA_BASE
By default, CATALINA_HOME and CATALINA_BASE point to the same directory. Set CATALINA_BASE manually when you require running multiple Tomcat instances on one machine. Doing so provides the following benefits:
默认情况下,CATALINA_HOME 和 CATALINA_BASE 指向同一目录。当您需要在一台计算机上运行多个 Tomcat 实例时,请手动设置 CATALINA_BASE。这样做有以下好处:
- Easier management of upgrading to a newer version of Tomcat. Because all instances with single CATALINA_HOME location share one set of .jar files and binary files, you can easily upgrade the files to newer version and have the change propagated to all Tomcat instances using the same CATALIA_HOME directory.
- 更轻松地管理升级到更新版本的 Tomcat。由于具有单个 CATALINA_HOME 位置的所有实例共享一组 .jar 文件和二进制文件,因此您可以轻松地将文件升级到较新版本,并使用相同的 CATALIA_HOME 目录将更改传播到所有 Tomcat 实例。
- Avoiding duplication of the same static .jar files.
- 避免重复相同的静态.jar文件。
- The possibility to share certain settings, for example the setenv shell or bat script file (depending on your operating system).
- 共享某些设置的可能性,例如setenv shell或bat脚本文件(取决于您的操作系统)。
4.2.Contents of CATALINA_BASE
Before you start using CATALINA_BASE, first consider and create the directory tree used by CATALINA_BASE. Note that if you do not create all the recommended directories, Tomcat creates the directories automatically. If it fails to create the necessary directory, for example due to permission issues, Tomcat will either fail to start, or may not function correctly.
在开始使用 CATALINA_BASE 之前,首先考虑并创建 CATALINA_BASE 使用的目录树。请注意,如果您不创建所有推荐的目录,Tomcat 会自动创建目录。如果无法创建必须的目录,例如由于权限问题,Tomcat 将无法启动,或者可能无法正常运行。
Consider the following list of directories:
请考虑以下目录列表:
-
The bin directory with the setenv.sh, setenv.bat, and tomcat-juli.jar files.
Recommended: No.
Order of lookup: CATALINA_BASE is checked first; fallback is provided to CATALINA_HOME.
-
在 bin 与目录 setenv.sh, setenv.bat, 和 tomcat-juli.jar 文件。 推荐:不。 查找顺序:首先检查 CATALINA_BASE; 回退提供给 CATALINA_HOME。
-
The lib directory with further resources to be added on classpath.
Recommended: Yes, if your application depends on external libraries.
Order of lookup: CATALINA_BASE is checked first; CATALINA_HOME is loaded second.
-
lib 具有要在类路径上添加的更多资源的目录。 推荐:是的,如果您的应用程序依赖于外部库。 查找顺序:首先检查 CATALINA_BASE; CATALINA_HOME 第二次加载。
-
The logs directory for instance-specific log files.
Recommended: Yes.
-
该logs目录实例特定的日志文件。 推荐:是的。
-
The webapps directory for automatically loaded web applications.
Recommended: Yes, if you want to deploy applications.
Order of lookup: CATALINA_BASE only.
-
webapps 自动加载的Web应用程序 的目录。 推荐:是的,如果要部署应用程序。 查找顺序:仅限 CATALINA_BASE。
-
The work directory that contains temporary working directories for the deployed web applications.
Recommended: Yes.
-
work 目录包含用于部署的Web应用程序的临时工作目录目录。 推荐:是的。
-
The temp directory used by the JVM for temporary files.
Recommended: Yes.
-
temp 目录被JVM用来存放临时文件。 推荐:是的。
We recommend you not to change the tomcat-juli.jar file. However, in case you require your own logging implementation, you can replace the tomcat-juli.jar file in a CATALINA_BASE location for the specific Tomcat instance.
我们建议您不要更改tomcat-juli.jar文件。但是,如果您需要自己的日志记录实现,则可以替换tomcat-juli.jar特定Tomcat实例的 CATALINA_BASE 位置中的文件。
We also recommend you copy all configuration files from the CATALINA_HOME/conf directory into the CATALINA_BASE/conf/ directory. In case a configuration file is missing in CATALINA_BASE, there is no fallback to CATALINA_HOME. Consequently, this may cause failure.
At minimum, CATALINA_BASE must contain:
我们还建议您将 CATALINA_HOME/conf 目录中的所有配置文件复制 到 CATALINA_BASE/conf/目录中。如果CATALINA_BASE中缺少配置文件,则不会回退到 CATALINA_HOME。因此,这可能会导致失败。
至少,CATALINA_BASE必须包含:
- conf/server.xml
- conf/web.xml
That includes the conf directory. Otherwise, Tomcat fails to start, or fails to function properly.
For advanced configuration information, see the file.
那包括conf目录。否则,Tomcat无法启动或无法正常运行。
有关高级配置信息,请参阅 文件。
4.3.How to Use CATALINA_BASE
The CATALINA_BASE property is an environment variable. You can set it before you execute the Tomcat start script, for example:
CATALINA_BASE属性是一个环境变量。您可以在执行Tomcat启动脚本之前进行设置,例如:
- On Unix: CATALINA_BASE=/tmp/tomcat_base1 bin/catalina.sh start
- On Windows: CATALINA_BASE=C:\tomcat_base1 bin/catalina.bat start
5.Configuring Tomcat
This section will acquaint you with the basic information used during the configuration of the container.
All of the information in the configuration files is read at startup, meaning that any change to the files necessitates a restart of the container.
本节将使您了解容器配置期间使用的基本信息。
配置文件中的所有信息都在启动时读取,这意味着对文件的任何更改都需要重新启动容器。
6.Where to Go for Help
While we've done our best to ensure that these documents are clearly written and easy to understand, we may have missed something. Provided below are various web sites and mailing lists in case you get stuck.
虽然我们已尽最大努力确保这些文件清晰易读,但我们可能错过了一些内容。下面提供了各种网站和邮件列表,以防您遇到困难。
Keep in mind that some of the issues and solutions vary between the major versions of Tomcat. As you search around the web, there will be some documentation that is not relevant to Tomcat 9, but only to earlier versions.
请记住,Tomcat的主要版本之间的一些问题和解决方案各不相同。当您在网上搜索时,会有一些与Tomcat 9无关的文档,但仅限于早期版本。
- Current document - most documents will list potential hangups. Be sure to fully read the relevant documentation as it will save you much time and effort. There's nothing like scouring the web only to find out that the answer was right in front of you all along!
- Tomcat FAQ at
- Tomcat mailing list archives - numerous sites archive the Tomcat mailing lists. Since the links change over time, clicking here will search .
- The TOMCAT-USER mailing list, which you can subscribe to . If you don't get a reply, then there's a good chance that your question was probably answered in the list archives or one of the FAQs. Although questions about web application development in general are sometimes asked and answered, please focus your questions on Tomcat-specific issues.
- The TOMCAT-DEV mailing list, which you can subscribe to . This list is reserved for discussions about the development of Tomcat itself. Questions about Tomcat configuration, and the problems you run into while developing and running applications, will normally be more appropriate on the TOMCAT-USER list instead.
- 当前文档 - 大多数文档将列出潜在的挂起。请务必完整阅读相关文档,因为这样可以节省您的大量时间和精力。没有什么比搜索网络只是为了找到答案就在你面前一直在你面前!
- Tomcat 常见问题解答
- Tomcat 邮件列表存档 - 众多站点存档Tomcat邮件列表。由于链接会随着时间的推移而变化,点击此处将搜索 。
- TOMCAT-USER 邮件列表,您可以在订阅 。如果您没有得到答复,那么很可能您的问题可能会在列表存档或其中一个常见问题解答中得到解答。虽然有时会询问和回答有关 Web 应用程序开发的问题,但请将您的问题集中在 Tomcat 特定的问题上。
- TOMCAT-DEV邮件列表,您可以在订阅 。此列表 保留用于讨论Tomcat本身的开发。有关Tomcat配置的问题以及在开发和运行应用程序时遇到的问题通常更适合 TOMCAT-USER 列表。
And, if you think something should be in the docs, by all means let us know on the TOMCAT-DEV list.
并且,如果您认为某些内容应该在文档中,请务必在TOMCAT-DEV列表中告知我们。