Tomcat server.xml标签解释

Server

1.1 In the Tomcat world, a Server represents the whole container. Tomcat provides a default implementation of theServer interface., and this is rarely customized by users.

1.2 tomcat的世界里,一个server代表整个容器.Tomcat提供了一个默认的org.apache.catalina接口的实现.用户很少修改这个默认的实现

 

Service

2.1 A Service is an intermediate component which lives inside a Server and ties one or more Connectors to exactly one Engine. The Service element is rarely customized by users, as the default implementation is simple and sufficient: Service interface.

2.2 一个Service是一个中间件,存在在一个Server的内部,将一个或者多个Connectors绑定到一个特定的Engine.默认的实现已经足够用了.org.apache.catalina.Service接口的一个实现.

A "Service" is a collection of one or more "Connectors" that share a single "Container"

一个Service是一个或者多个Connectors的集合,这些个Connectors共享一个容器。

Engine

3.1 An Engine represents request processing pipeline for a specific Service. As a Service may have multiple Connectors, the Engine received and processes all requests from these connectors, handing the response back to the appropriate connector for transmission to the client. The Engine interface may be implemented to supply custom Engines, though this is uncommon.

3.2 一个Engine代表一个特定的Service的请求处理的管道.因为一个Service可以有多个Connectors,Engine接收并且处理从这些Connectors过来的所有的请求.并且将结果送回合适的connector并发送给客户端.

3.3 可以实现org.apache.catalina.Interface Engine接口来提供定制的Engines,虽然一般不需要这样做.

3.4 Note that the Engine may be used for Tomcat server clustering via the jvmRoute parameter. Read the Clustering documentation for more information.

Host

4.1 A Host is an association of a network name, e.g. www.yourcompany.com, to the Tomcat server. An Engine may contain multiple hosts, and the Host element also supports network aliases such as yourcompany.com and abc.yourcompany.com. Users rarely create customHosts because the StandardHost implementation provides significant additional functionality.

4.2 一个Host将一个域名和tomcat联系起来.一个Engine可以包含多个hosts,并且一个Host还支持网络别名(例如yourcompany.com 或者 abc.yourcompany.com).用户很少去实现一个org.apache.catalina.Interface Host接口,因为org.apache.catalina.core.StandardHost这个默认的实现已经提供了丰富的扩展功能了

 

Connector

5.1 A Connector handles communications with the client. There are multiple connectors available with Tomcat, all of which implement theConnector interface. These include theCoyote connector which is used for most HTTP traffic, especially when running Tomcat as a standalone server, and theJK2 connector which implements the AJP procotol used when connecting Tomcat to an Apache HTTPD server. Creating a customized connector is a significant effort.

5.2 一个Connector处理和客户端的通信.tomcat有多个connectors.这些个connectors都实现了Connector接口.

5.3 创建一个定制的connector是非常复杂的.

5.4 AJP是为TomcatHTTP服务器之间通信而定制的协议,能提供较高的通信速度和效率。在配置TomcatHTTP服务器集成中,读者可以不必关心AJP协议的细节。关于AJP的知识也可以参考网址:

5.5 Tomcat最主要的功能是提供Servlet/JSP容器,尽管它也可以作为独立的Java Web服务器,它在对静态资源(如HTML文件或图像文件)的处理速度,以及提供的Web服务器管理功能方面都不如其他专业的HTTP服务器,如IISApache服务器。

5.6 因此在实际应用中,常常把Tomcat与其他HTTP服务器集成。对于不支持Servlet/JSPHTTP服务器,可以通过Tomcat服务器来运行Servlet/JSP组件。

5.7 Tomcat与其他HTTP服务器集成时,Tomcat服务器的工作模式通常为进程外的Servlet容器,Tomcat服务器与其他HTTP服务器之间通过专门的插件来通信。

5.8 TomcatHTTP服务器集成的原理:Tomcat服务器通过Connector连接器组件与客户程序建立连接,Connector组件负责接收客户的请求,以及把Tomcat服务器的响应结果发送给客户。默认情况下,Tomcatserver.xml中配置了两种连接器:

l <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />

l <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

5.9 第一个连接器监听8080端口,负责建立HTTP连接。在通过浏览器访问Tomcat服务器的Web应用时,使用的就是这个连接器。

5.10 第二个连接器监听8009端口,负责和其他的HTTP服务器建立连接。在把Tomcat与其他HTTP服务器集成时,就需要用到这个连接器。

5.11 Tomcat提供了专门的JK插件来负责TomcatHTTP服务器的通信。应该把JK插件安置在对方的HTTP服务器上。

5.12 对于不同的HTTP服务器,Tomcat提供了不同的JK插件的实现模块

Windows下的Apache HTTP服务器集成:mod_jk_2.0.46.dll

LinuxRedHet)下的Apache HTTP服务器集成:mod_jk.so-ap2.0.46-rh72..46-rh72

IIS服务器集成:isapi_redirect.dll

5.13 AJP是为TomcatHTTP服务器之间通信而定制的协议,能提供较高的通信速度和效率。

5.14 关于AJP的知识也可以参考网址:
http://jakarta.apache.org/builds/jakarta-tomcat-connectors/jk2/doc/common/AJPv13.html

5.15 如果两个Tomcat服务器都在同一台机器上运行,则至少应该对其中一个Tomcat服务器的以上3个端口号都进行修改。

Context

6.1 A Context represents a web application. A Host may contain multiple contexts, each with a unique path. TheContext interface may be implemented to create custom Contexts, but this is rarely the case because theStandardContext provides significant additional functionality.

6.2 一个Context代表一个web应用程序。一个Host可以包含多个contexts。每一个有不同的访问地址。

6.3 可以实现Context接口来创建自己的Contexts。但很少这样用,因为StandardContext已经提供了丰富的额外的功能

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Tomcat是一款高性能的Web服务器,而其中的配置文件server.xml是非常重要的一个组成部分。下面就来详细解释一下server.xml文件的配置项。 1. Server元素 Server元素是整个Tomcat的顶层元素,它有一个默认的端口号8005,称为Shutdown端口号,可用于远程关闭Tomcat。此外,还可以配置JNDI资源、全局JSP页面、日志配置等。 2. Service元素 Service元素包含一个或多个Connector元素、一个或多个Engine元素和一个Executor元素。其中,Connector元素用于设置HTTP协议的监听端口号、IP地址和协议类型等;Engine元素用于配置Web站点的名称和默认主机(host)等;Executor元素用于配置Servlet的线程池。 3. Connector元素 Connector元素是Tomcat服务器接收客户端连接请求的组件,它会对应一个通信协议(如:HTTP、HTTPS、AJP等)和监听的IP地址、端口号等。http连接器中还包括了各种协议支持,如HTTPS支持、http/2等等。 4. Engine元素 Engine元素用于描述一个逻辑的Web站点,一般只配置一个Engine,但也可以多个,个数随实际需求而定。Engine元素包括虚拟主机Host元素、全局JSP配置以及日志配置等。 5. Host元素 Host元素用于设置虚拟主机的基本信息,包括主机名、别名、访问日志、错误日志等。 6. Context元素 Context元素是Web应用程序的配置单元。一个Host元素通常包含多个Context元素,每个Context代表一个不同的应用程序,Context还包括web.xml文件、标签库文件等等。 7. Executor元素 Executor元素用于配置Servlet的线程池,这对于高并发的Web应用程序的性能至关重要,它包括线程池的名称、线程池的大小等信息。 以上就是Tomcat服务器配置文件server.xml的详细解释,理解这些配置选项和意义后,能够更好地配置Tomcat服务器,以满足Web应用的需求。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值