Deployment is the term used for the process of installing a web application (either a 3rd party WAR or your own custom web application) into the Tomcat server.html
部署是用於將Web應用程序(第三方WAR或您本身的自定義Web應用程序)安裝到Tomcat服務器的過程當中的術語。java
Web application deployment may be accomplished in a number of ways within the Tomcat server.web
Web應用程序部署能夠在Tomcat服務器中以多種方式完成。shell
The Tomcat Manager is a web application that can be used interactively (via HTML GUI) or programmatically (via URL-based API) to deploy and manage web applications.apache
在Tomcat管理器是一個能夠交互使用(經過HTML GUI)或以編程方式(經過基於URL的API)來部署和管理Web應用程序的Web應用程序。編程
There are a number of ways to perform deployment that rely on the Manager web application. Apache Tomcat provides tasks for Apache Ant build tool. Apache Tomcat Maven Plugin project provides integration with Apache Maven. There is also a tool called the Client Deployer, which can be used from a command line and provides additional functionality such as compiling and validating web applications as well as packaging web application into web application resource (WAR) files.tomcat
有許多方法能夠執行依賴Manager Web應用程序的部署。Apache Tomcat爲Apache Ant構建工具提供任務。 Apache Tomcat Maven插件 項目提供與Apache Maven的集成。還有一個名爲Client Deployer的工具,能夠從命令行使用它,並提供其餘功能,例如編譯和驗證Web應用程序以及將Web應用程序打包到Web應用程序資源(WAR)文件中。服務器
There is no installation required for static deployment of web applications as this is provided out of the box by Tomcat. Nor is any installation required for deployment functions with the Tomcat Manager, although some configuration is required as detailed in the Tomcat Manager manual. An installation is however required if you wish to use the Tomcat Client Deployer (TCD).session
靜態部署Web應用程序不須要安裝,由於Tomcat提供了開箱即用的功能。儘管Tomcat Manager手冊中詳細說明了某些配置,但Tomcat Manager的部署功能也不須要任何安裝 。可是,若是您但願使用Tomcat客戶端部署程序(TCD),則須要安裝。app
The TCD is not packaged with the Tomcat core distribution, and must therefore be downloaded separately from the Downloads area. The download is usually labelled apache-tomcat-9.0.x-deployer.
TCD未與Tomcat核心發行版一塊兒打包,所以必須從「下載」區域單獨下載。下載一般標記爲 apache-tomcat-9.0.x-deployer。
TCD has prerequisites of Apache Ant 1.6.2+ and a Java installation. Your environment should define an ANT_HOME environment value pointing to the root of your Ant installation, and a JAVA_HOME value pointing to your Java installation. Additionally, you should ensure Ant's ant command, and the Java javac compiler command run from the command shell that your operating system provides.
TCD具備Apache Ant 1.6.2+和Java安裝的先決條件。您的環境應定義指向Ant安裝根目錄的ANT_HOME環境值,以及指向Java安裝的JAVA_HOME值。此外,您應該確保Ant的ant命令,而且Java javac編譯器命令從您的操做系統提供的命令shell運行。
In talking about deployment of web applications, the concept of a Context is required to be understood. A Context is what Tomcat calls a web application.
在談論Web應用程序的部署時,須要理解Context的概念 。Context是Tomcat稱之爲Web應用程序的。
In order to configure a Context within Tomcat a Context Descriptor is required. A Context Descriptor is simply an XML file that contains Tomcat related configuration for a Context, e.g naming resources or session manager configuration. In earlier versions of Tomcat the content of a Context Descriptor configuration was often stored within Tomcat's primary configuration file server.xmlbut this is now discouraged (although it currently still works).
爲了在Tomcat中配置Context, 須要一個Context Descriptor。上下文描述符只是一個XML文件,它包含上下文的Tomcat相關配置,例如命名資源或會話管理器配置。在早期版本的Tomcat中,Context Descriptor配置的內容一般存儲在Tomcat的主配置文件server.xml中,但如今不建議這樣作(儘管它目前仍然有效)。
Context Descriptors not only help Tomcat to know how to configure Contexts but other tools such as the Tomcat Manager and TCD often use these Context Descriptors to perform their roles properly.
上下文描述符不只幫助Tomcat知道如何配置上下文,並且其餘工具(如Tomcat Manager和TCD)一般使用這些上下文描述符來正確執行其角色。
The locations for Context Descriptors are:
上下文描述符的位置是:
Files in (1) are named [webappname].xml but files in (2) are named context.xml. If a Context Descriptor is not provided for a Context, Tomcat configures the Context using default values.
(1)中的文件名爲[webappname] .xml,但(2)中的文件名爲context.xml。若是沒有爲Context提供Context Descriptor,Tomcat將使用默認值配置Context。
If you are not interested in using the Tomcat Manager, or TCD, then you'll need to deploy your web applications statically to Tomcat, followed by a Tomcat startup. The location you deploy web applications to for this type of deployment is called the appBase which is specified per Host. You either copy a so-called exploded web application, i.e non-compressed, to this location, or a compressed web application resource .WAR file.
若是您對使用Tomcat Manager或TCD不感興趣,那麼您須要將Web應用程序靜態部署到Tomcat,而後是Tomcat啓動。您爲此類部署部署Web應用程序的位置稱爲 appBase 每一個主機指定的位置。您能夠將所謂的展開的Web應用程序(即非壓縮的)複製到此位置,或壓縮的Web應用程序資源.WAR文件。
The web applications present in the location specified by the Host's (default Host is "localhost") appBase attribute (default appBase is "$CATALINA_BASE/webapps") will be deployed on Tomcat startup only if the Host's deployOnStartup attribute is "true".
appBase僅當主機的deployOnStartup屬性爲「true」時,將在Tomcat啓動時部署 由主機(默認主機爲「localhost」)屬性指定的位置中的Web應用程序(默認appBase爲「$ CATALINA_BASE / webapps」)。
The following deployment sequence will occur on Tomcat startup in that case:
在這種狀況下,Tomcat啓動時將發生如下部署順序:
It is possible to deploy web applications to a running Tomcat server.
能夠將Web應用程序部署到正在運行的Tomcat服務器。
If the Host autoDeploy attribute is "true", the Host will attempt to deploy and update web applications dynamically, as needed, for example if a new .WAR is dropped into the appBase
. For this to work, the Host needs to have background processing enabled which is the default configuration.
若是Host autoDeploy 屬性爲「true」,則Host將嘗試根據須要動態部署和更新Web應用程序,例如,若是將新的.WAR放入其中appBase。爲此,主機須要啓用後臺處理,這是默認配置。
autoDeploy 設置爲「true」,運行Tomcat容許:
autoDeploy set to "true" and a running Tomcat allows for:
Note that web application reloading can also be configured in the loader, in which case loaded classes will be tracked for changes.
若是刪除了其文檔庫(docBase),則取消部署Web應用程序。請注意,在Windows上,這假定啓用了反鎖定功能(請參閱上下文配置),不然沒法刪除正在運行的Web應用程序的資源。
The Tomcat Manager is covered in its own manual page.
Tomcat Manager包含在本身的手冊頁中。
Finally, deployment of web application may be achieved using the Tomcat Client Deployer. This is a package which can be used to validate, compile, compress to .WAR, and deploy web applications to production or development Tomcat servers. It should be noted that this feature uses the Tomcat Manager and as such the target Tomcat server should be running.
最後,能夠使用Tomcat Client Deployer實現Web應用程序的部署。這是一個包,可用於驗證,編譯,壓縮到.WAR,以及將Web應用程序部署到生產或開發Tomcat服務器。應該注意,此功能使用Tomcat Manager,所以目標Tomcat服務器應該運行。
It is assumed the user will be familiar with Apache Ant for using the TCD. Apache Ant is a scripted build tool. The TCD comes pre-packaged with a build script to use. Only a modest understanding of Apache Ant is required (installation as listed earlier in this page, and familiarity with using the operating system command shell and configuring environment variables).
假設用戶熟悉Apache Ant以使用TCD。Apache Ant是一個腳本化的構建工具。TCD預先打包了要使用的構建腳本。只須要對Apache Ant有必定的瞭解(本頁前面列出的安裝,熟悉使用操做系統命令shell和配置環境變量)。
The TCD includes Ant tasks, the Jasper page compiler for JSP compilation before deployment, as well as a task which validates the web application Context Descriptor. The validator task (class org.apache.catalina.ant.ValidatorTask allows only one parameter: the base path of an exploded web application.
TCD包括Ant任務,部署前用於JSP編譯的Jasper頁面編譯器,以及驗證Web應用程序上下文描述符的任務。驗證器任務(類 org.apache.catalina.ant.ValidatorTask )僅容許一個參數:爆炸Web應用程序的基本路徑。
The TCD uses an exploded web application as input (see the list of the properties used below). A web application that is programmatically deployed with the deployer may include a Context Descriptor in /META-INF/context.xml.
TCD使用爆炸的Web應用程序做爲輸入(請參閱下面使用的屬性列表)。以部署程序編程部署的Web應用程序能夠包括上下文描述符 /META-INF/context.xml。
The TCD includes a ready-to-use Ant script, with the following targets:
TCD包含一個即用型Ant腳本,具備如下目標:
In order for the deployment to be configured, create a file called deployer.properties in the TCD installation directory root. In this file, add the following name=value pairs per line:
爲了配置部署,請建立deployer.properties 在TCD安裝目錄root中調用的文件。在此文件中,每行添加如下name = value對:
Additionally, you will need to ensure that a user has been setup for the target Tomcat Manager (which TCD uses) otherwise the TCD will not authenticate with the Tomcat Manager and the deployment will fail. To do this, see the Tomcat Manager page.
此外,您須要確保已爲目標Tomcat Manager(TCD使用)設置了用戶,不然TCD將不會使用Tomcat Manager進行身份驗證,部署將失敗。要執行此操做,請參閱Tomcat Manager頁面。