02-《Apache Tomcat 9 User Guide》之简介

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.html

对于管理员和Web开发人员来讲,在开始以前,您应该熟悉一些重要的信息。本文档简要介绍了Tomcat容器背后的一些概念和术语。一样的,当你须要帮助时告诉你去哪里找答案。web

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 Servlet and JSP specifications.shell

在阅读这些文件的过程当中,您将遇到许多术语; 一些特定于Tomcat的,以及其余由Servlet和JSP规范定义的 。apache

  • 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.tomcat

上述这些,若是您发现咱们须要在此部分添加更多字词,请告知咱们。网络

3.Directories and Files - 目录和文件

These are some of the key tomcat directories:app

这些是一些关键的tomcat目录:webapp

  • /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:jsp

在整个文档中,引用了如下两个属性:ide

  • 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 RUNNING.txt file.

那包括conf目录。不然,Tomcat没法启动或没法正常运行。

有关高级配置信息,请参阅 RUNNING.txt 文件。

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
  • Tomcat WIKI
  • Tomcat FAQ at jGuru
  • Tomcat mailing list archives - numerous sites archive the Tomcat mailing lists. Since the links change over time, clicking here will search Google.
  • The TOMCAT-USER mailing list, which you can subscribe to here. 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 here. 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 FAQ
  • Tomcat WIKI
  • jguru的 Tomcat 常见问题解答
  • Tomcat 邮件列表存档 - 众多站点存档Tomcat邮件列表。因为连接会随着时间的推移而变化,点击此处将搜索 Google
  • 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列表中告知咱们。

 

      声明,本文内容来自于Apache基金会官网关于Tomcat项目的官方文档,本人在原文档内容基础上整理总结而得,中文翻译仅供参考,英语不还错的童鞋,能够直接去官方查看最新的官方文档哦!!!若是以为对你有帮助,不要忘了点赞,评论,转发哟!!!

相关文章
相关标签/搜索