Tomcat翻译--Tomcat Web Application Deployment(Tomcat中部署web应用)

时间:2022-09-03 11:37:16

原文:http://tomcat.apache.org/tomcat-7.0-doc/deployer-howto.html

Introduction(介绍)

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.

【“部署”是用来表示在Tomcat服务器上安装一个web应用(或者第三方war包以及你自定义的web应用)的术语。】

Web application deployment may be accomplished in a number of ways within the Tomcat server.

【部署web应用在tomcat中有多种实现方式。】

Statically; the web application is setup before Tomcat is started

Dynamically; by directly manipulating already deployed web applications (relying on auto-deployment feature) or remotely by using the Tomcat Manager web application

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.

【静态部署:在tomcat启动之前就安装好的web应用;】

【动态部署:通过直接操作或者通过tomcat manager远程操作已经部署好的web应用(依赖自动部署特性)。】

【tomcat manager本身就是一个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.

【你可以使用Manager应用,通过多种方式进行部署。Apache Tomcat提供了Apache Ant构建工具来执行部署;Apache Tomcat Maven Plugin提供了与Maven的集成;还有一个名为Client Deployer的工具,你可以通过命令行来使用,这个工具还提供了一些额外的功能,比如编译、验证、打包等。】

Installation(安装)

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

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-7.0.x-deployer.

【静态部署web应用时,不需要在tomcat中安装任何东西,因为这是tomcat本身就提供的功能;也不需要在tomcat manager中安装任何东西,尽管tomcat manager的操作手册中提到了会需要一些配置。但如果你想使用tomcat client deployer(TCD)的话,则需要进行安装。tomcat核心发行版中没有包含TCD,因此你需要单独下载,下载链接一般会被标记为”apache-tomcat-7.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_HOME环境变量,指向Ant的安装目录,以及一个JAVA_HOME环境变量,指向Java的安装目录。除此之外,还需要保证ant命令和javac命令可以在你的操作系统的命令行中正常运行。】

Download the TCD distribution【下载TCD发行版】

The TCD package need not be extracted into any existing Tomcat installation, it can be extracted to any location.

Read Using the Tomcat Client Deployer

【TCD包可以被解压到任何位置,而不需要被解压到Tomcat的安装目录中。你可以参考“Tomcat Client Deployer的使用”这一小节。]

A word on Contexts(Context概述)

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的含义。在tomcat中,一个Context就表示一个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.xml but this is now discouraged (although it currently still works).

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中配置一个Context,需要一个Context Descriptor。Context Descriptor是一个包含Context的相关配置的XML文件,比如资源标识或者会话管理器配置。在早先的Tomcat版本中,Context Descriptor配置经常被放在server.xml文件中,但现在已经不鼓励这么做(尽管依然可以这么做)。】

【Context Descriptor不仅帮助Tomcat了解怎样配置Context,而且其他的一些工具,比如Tomcat Manager以及TCD,也经常使用这些Context Descriptor来执行它们的功能。】

The locations for Context Descriptors are:

1.$CATALINA_BASE/conf/[enginename]/[hostname]/[webappname].xml

2.$CATALINA_BASE/webapps/[webappname]/META-INF/context.xml

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.

【Context Descriptor存放的位置如下:】

【1.$CATALINA_BASE/conf/[enginename]/[hostname]/[webappname].xml】

【2..$CATALINA_BASE/webapps/[webappname]/META-INF/context.xml】

【(1)中的文件名是[webappname].xml,(2)中的文件名是context.xml。如果一个Context没有提供Context Descriptor,则Tomcat会为用缺省值配置Context。】

Deployment on Tomcat startup【在Tomcat启动时部署】

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.

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

【如果不想使用Tomcat Manager或者TCD,那么可以将web应用静态部署到tomcat上,接着再启动tomcat。对于每一个指定的Host,web应用应该被部署在appBase目录下,你可以在appBase目录下部署未解压的.war文件或者解压后的web应用。】

【当Host的deployOnStartup属性为true时,位于Host(缺省值为“localhost”)中的appBase属性(缺省值为"$CATALINA_BASE/webapps")下的web应用将随tomcat的启动而被自动部署。]

The following deployment sequence will occur on Tomcat startup in that case:

Any Context Descriptors will be deployed first.

Exploded web applications not referenced by any Context Descriptor will then be deployed. Note that if an exploded web application has an associated .WAR file in the appBase, Tomcat will not detect if the associated .WAR has been updated while Tomcat was stopped and will deploy the exploded web application as is. The exploded web application will not be removed and replaced with the contents of the updated .WAR file.

.WAR files will be deployed

【tomcat启动时,部署按照以下步骤顺序执行:】

【首先部署的是Context Descriptor。然后部署Context Descriptor中没有涉及到的已解压的web应用。注意,如果一个已解压的web应用在appBase下有一个相对应的.war文件,则tomcat不会检测自从上次关闭后,该.war文件是否被更新,而只是部署该解压后的web应用。解压后的web应用不会被移除,也不会被更新后的.war文件的内容替换。最后被部署的是.war文件。】

总结:tomcat启动时部署顺序如下:

1.部署$CATALINA_BASE/conf/[enginename]/[hostname]/[webappname].xml以及$CATALINE_BASE/webapps/[webappname]/META-INF/context.xml;

2.部署appBase下已经被解压的web应用;

3.部署appBase下的.war文件。

注:

(1)部署appBase下的已解压web应用以及.war文件,指的是appBase/这一级目录,不包括其他的子目录,也就是说,除了appBase/这一级目录下的web应用以及.war文件会被自动部署之外,其他的web应用以及.war文件不会被自动部署(.war文件也不会被自动解压)

(2)静态部署时,如果存在一个已解压的web应用,以及一个同名的未解压的web应用,则tomcat不会检测到自动上次关闭后,该.war文件是否被更新,而只会部署解压后的web应用,不会部署.war文件。只有在tomat启动后,当.war文件被修改后,才会更新相应的解压的web应用,即热部署。

Deploying on a running Tomcat server(在tomcat运行时部署,即热部署)

It is possible to deploy web applications to a running Tomcat server.

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.

【在tomcat运行时也可以部署web应用。】

【如果主机的autoDeploy属性被设置为true,那么该主机在需要时会尝试动态部署及更新web应用。比如,如果一个appBase中添加了一个新的.war文件,则该主机就会动态解压并部署该web应用。为了实现这个目的,主机必须有一个具有默认配置的后台进程】

autoDeploy set to "true" and a running Tomcat allows for:

Deployment of .WAR files copied into the Host appBase.

Deployment of exploded web applications which are copied into the Host appBase.

Re-deployment of a web application which has already been deployed from a .WAR when the new .WAR is provided. In this case the exploded web application is removed, and the .WAR is expanded again. Note that the explosion will not occur if the Host is configured so that .WARs are not exploded with a unpackWARs attribute set to "false", in which case the web application will be simply redeployed as a compressed archive.

Re-loading of a web application if the /WEB-INF/web.xml file (or any other resource defined as a WatchedResource) is updated.

Re-deployment of a web application if the Context Descriptor file from which the web application has been deployed is updated.

Re-deployment of dependent web applications if the global or per-host Context Descriptor file used by the web application is updated.

Re-deployment of a web application if a Context Descriptor file (with a filename corresponding to the Context path of the previously deployed web application) is added to the $CATALINA_BASE/conf/[enginename]/[hostname]/ directory.

Undeployment of a web application if its document base (docBase) is deleted. Note that on Windows, this assumes that anti-locking features (see Context configuration) are enabled, otherwise it is not possible to delete the resources of a running web application.

【autoDeploy设为true,允许tomcat在运行时执行以下操作:】

【部署放到appBase下的.war文件;】

【部署放到appBase下的解压的web应用;】

【如果解压的web应用在appBase目录下还有一个相对应的.war文件,且该.war文件被更新了,此时,原先的web应用被移除,更新后的.war文件会被再次解压并部署。需要注意的是,如果unpackWars属性被设置为false,则不会像前面所说的那样对.war文件进行解压并部署;】

【如果/WEB-INF/web.xml文件或者任何被WatchedResource元素指定的资源发生更新,则对应的web应用会被重新部署;】

【如果Context Descriptor文件中描述的web应用被更新了,则重新部署该web应用;】

【如果web应用使用的全局或者per-host的Context Descriptor文件被更新,则该web应用会被重新部署;】

【如果在$CATALINA_BASE/conf/[enginename]/[hostname]/目录下增加了一个Context Descriptor文件(文件名与先前部署的web应用的Context path相同),则该web应用被重新部署;】

【如果一个web应用的docBase被删除,则该web应用被卸载。注意,在windows下,该特性假设anti-locking特性已被设置,否则不允许删除运行中的web应用的资源;】

Tomcat翻译--Tomcat Web Application Deployment(Tomcat中部署web应用)的更多相关文章

  1. 在Tomcat中部署Web项目的操作方法,maven项目在Tomcat里登录首页报404

     maven项目在Tomcat里登录首页报404, 解决:编辑conf/server.xml进行配置<Host>里的<Context>标签里的path. <Context ...

  2. 在Tomcat中部署web项目的三种方式

    搬瓦工搭建SS教程 SSR免费节点:http://www.xiaokeli.me 在这里介绍在Tomcat中部署web项目的三种方式: 1.部署解包的webapp目录 2.打包的war文件 3.Man ...

  3. Tomcat中部署web应用的三种方式

    Tomcat中部署web应用的三种方式(静态部署)       第一种,针对war或解压后的war,最为常用的是直接操作webapp目录,将完整的war包或者web应用直接放到webapp目录下.使用 ...

  4. Tomcat 中部署 web 应用 ---- Dubbo 服务消费者 Web 应用 war 包的部署

    使用Maven构建Dubbo服务的可执行jar包 Dubbo服务的运行方式: 1.使用Servlet容器运行(Tomcat.Jetty等)----不可取 缺点:增加复杂性(端口.管理) 浪费资源(内存 ...

  5. The &quot&semi;web&period;xml&quot&semi; is called web application deployment descriptor

    3.3  Configure the Application Deployment Descriptor - "web.xml" A web user invokes a serv ...

  6. 返璞归真 asp&period;net mvc &lpar;11&rpar; - asp&period;net mvc 4&period;0 新特性之自宿主 Web API&comma; 在 WebForm 中提供 Web API&comma; 通过 Web API 上传文件&comma; &period;net 4&period;5 带来的更方便的异步操作

    原文:返璞归真 asp.net mvc (11) - asp.net mvc 4.0 新特性之自宿主 Web API, 在 WebForm 中提供 Web API, 通过 Web API 上传文件, ...

  7. Tomcat:Custom a common error page valve for all web application in tomcat

    如果在一个Tomcat Server上会部署多个Web应用,又希望这多个Web应用共用一套错误页面,而不是使用默认的错误页面.就需要自定义错误页面了. 在每个web应用中都可以通过error-page ...

  8. Tomcat中部署WEB项目的四种方法

    对Tomcat部署web应用的方式总结,常见的有以下四种: 1.[使用控制台部署] 访问Http://localhost:8080,并通过Tomcat Manager登录,进入部署界面即可. 2.[利 ...

  9. Tomcat中部署web应用 ---- Dubbo服务消费者Web应用war包的部署

    样例视频:http://www.roncoo.com/course/view/f614343765bc4aac8597c6d8b38f06fd IP: 192.168.2.61 部署容器:apache ...

随机推荐

  1. &lbrack;译&rsqb;MVC网站教程(四):MVC4网站中集成jqGrid表格插件(系列完结)

    目录 1.   介绍 2.   软件环境 3.   在运行示例代码之前(源代码 + 示例登陆帐号) 4.         jqGrid和AJAX 5.         GridSettings 6.  ...

  2. i&plus;&plus;与&plus;&plus;i 辨析

    i++:先赋值在自加: ++i:先自加在赋值: 备注:在赋值运算中有区别,单独使用没有区别 ( 例子1:单独使用 for(int i=0;i<10;i++){ } for(int i=0;i&l ...

  3. 用slf4j&plus;logback实现多功能日志解决方案 --- 转

    大家都知道,slf4j是原来log4j的作者写的一个新的日志组件,意思是简单日志门面接口,可以跟其他日志组件配合使用,常用的配合是slf4j+logback,无论从功能上还是从性能上都较之log4j有 ...

  4. css行级块级区别总结摘录

    一.块级元素:block element 每个块级元素默认占一行高度,一行内添加一个块级元素后无法一般无法添加其他元素(float浮动后除外).两个块级元素连续编辑时,会在页面自动换行显示.块级元素一 ...

  5. logstash 中的贪婪匹配

    logstash 中的贪婪匹配: 10.252.142.174 - - [06/Sep/2016:08:41:36 +0800] "GET /api/validate/code/send?m ...

  6. ArrayList 源码(基于Java1&period;8)

    ArrayList 源码 ArrayList 基于数组实现,也就是类对变量 Object[]系列操作,封装为常用的add,remove,indexOf, contains本质是通过 size 计数器对 ...

  7. AssetManager

    AssetManager用于获取assets下的资源. 1.getassets()得到AssetManager 2.AssetManager.close() 关闭AssetManager 3.Reso ...

  8. 20165316 2017-2018-2《Java程序设计》课程总结

    20165316 2017-2018-2<Java程序设计>课程总结 一.每周作业链接汇总 1. 预备作业一:我期望的师生关系 20165316 我期望的师生关系 摘要: 典型老师 师生关 ...

  9. mysql 递归查询 主要是对于层级关系的查询

    最近遇到了一个问题,在mysql中如何完成节点下的所有节点或节点上的所有父节点的查询?在Oracle中我们知道有一个Hierarchical Queries可以通过CONNECT BY来查询,但是,在 ...

  10. 【实战】Oracle注入总结

    小结: Union联合查询: order by 定字段 and 1=2 union select null,null..... from dual 然后一个一个去判断字段类型,方法如下 and 1=2 ...