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項目的官方文檔,本人在原文檔內容基礎上整理總結而得,中文翻譯僅供參考,英語不還錯的童鞋,能夠直接去官方查看最新的官方文檔哦!!!若是以爲對你有幫助,不要忘了點贊,評論,轉發喲!!!

相關文章
相關標籤/搜索