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页面。