餐饮网站建设服务器,关键词排名技巧,今天国际大事新闻,一流门户网站建设前言 Tomcat主配置文件#xff08;server.xml#xff09;是Tomcat服务器的主要配置文件#xff0c;文件位置在conf目录下#xff0c;它包含了Tomcat的全局配置信息#xff0c;包括监听端口、虚拟主机、安全配置、连接器等。 目录
1 server.xml组件类别
2 组件介绍
3 se…前言 Tomcat主配置文件server.xml是Tomcat服务器的主要配置文件文件位置在conf目录下它包含了Tomcat的全局配置信息包括监听端口、虚拟主机、安全配置、连接器等。 目录
1 server.xml组件类别
2 组件介绍
3 server.xml配置文件详解
4 主要参数详解 4.1 Connector主要参数详解 4.2 host参数详解 4.3 Context参数说明 1 server.xml组件类别 顶级组件位于整个配置的顶层。如server。 容器类组件可以包含其他组件的组件。如service、engine、host、context。 连接器组件连接用户请求至Tomcat。如connector。 被嵌套类组件位于一个容器中不能包含其他组件。如value、logger。 2 组件介绍 组件名称 功能介绍 engine 核心容器组件定义Tomcat服务器内部的容器与Service元素一起定义了Tomcat服务器的整体架构。catalina引擎负责通过connector接收用户请求并处理请求将请求转至对应的虚拟主机host。 host 类似于httpd中的虚拟主机一般而言支持基于FQDN的虚拟主机允许在同一台服务器上运行多个网站或应用程序。 context 定义一个应用程序的上下文包括Web应用程序的路径、名称、文档根目录等是一个最内层的容器类组件(不能再嵌套)。配置context的主要目的指定对应的webapp的根目录类似于httpd的alias其还能为webapp指定额外的属性如部署方式等。 connector 定义Tomcat服务器与外部应用程序或客户端之间的连接接收用户请求通常用于HTTP或HTTPS通讯类似于httpd的listen配置监听端口。 Service 定义Tomcat服务器提供的服务通常包含一个或多个Connector连接器但只能有一个引擎engine。 Server 定义Tomcat服务器的全局属性其中的port属性定义了Tomcat服务器本身监听的端口号。 Valve 通过提供不同类型的阀门拦截请求并在将其转至对应的webapp前进行某种处理操作可以用于任何容器中比如记录日志(access log valve)、基于IP做访问控制(remote address filter valve)实现对Tomcat服务器的访问控制、流量控制、日志记录等功能。 loggor 日志记录器用于记录组件内部的状态信息可以用于除context外的任何容器中。 Realm 定义Tomcat服务器的安全认证和授权机制。可以用于任意容器类的组件中关联一个用户认证库实现认证和授权。可以关联的认证库有: UserDatabaseRealm使用JNDI自定义的用户认证库、MemoryRealm认证信息定义在tomcat-users.xml中和JDBCRealm认证信息定义在数据库中并通过JDBC连接至数据库中查找认证用户。 3 server.xml配置文件详解
server.xml 文件原版
?xml version1.0 encodingUTF-8?
!--Licensed to the Apache Software Foundation (ASF) under one or morecontributor license agreements. See the NOTICE file distributed withthis work for additional information regarding copyright ownership.The ASF licenses this file to You under the Apache License, Version 2.0(the License); you may not use this file except in compliance withthe License. You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an AS IS BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.
--
!-- Note: A Server is not itself a Container, so you may notdefine subcomponents such as Valves at this level.Documentation at /docs/config/server.html--
Server port8005 shutdownSHUTDOWNListener classNameorg.apache.catalina.startup.VersionLoggerListener /!-- Security listener. Documentation at /docs/config/listeners.htmlListener classNameorg.apache.catalina.security.SecurityListener /--!-- APR library loader. Documentation at /docs/apr.html --Listener classNameorg.apache.catalina.core.AprLifecycleListener SSLEngineon /!-- Prevent memory leaks due to use of particular java/javax APIs--Listener classNameorg.apache.catalina.core.JreMemoryLeakPreventionListener /Listener classNameorg.apache.catalina.mbeans.GlobalResourcesLifecycleListener /Listener classNameorg.apache.catalina.core.ThreadLocalLeakPreventionListener /!-- Global JNDI resourcesDocumentation at /docs/jndi-resources-howto.html--GlobalNamingResources!-- Editable user database that can also be used byUserDatabaseRealm to authenticate users--Resource nameUserDatabase authContainertypeorg.apache.catalina.UserDatabasedescriptionUser database that can be updated and savedfactoryorg.apache.catalina.users.MemoryUserDatabaseFactorypathnameconf/tomcat-users.xml //GlobalNamingResources!-- A Service is a collection of one or more Connectors that sharea single Container Note: A Service is not itself a Container,so you may not define subcomponents such as Valves at this level.Documentation at /docs/config/service.html--Service nameCatalina!--The connectors can use a shared executor, you can define one or more named thread pools--!--Executor nametomcatThreadPool namePrefixcatalina-exec-maxThreads150 minSpareThreads4/--!-- A Connector represents an endpoint by which requests are receivedand responses are returned. Documentation at :Java HTTP Connector: /docs/config/http.htmlJava AJP Connector: /docs/config/ajp.htmlAPR (HTTP/AJP) Connector: /docs/apr.htmlDefine a non-SSL/TLS HTTP/1.1 Connector on port 8080--Connector port8080 protocolHTTP/1.1connectionTimeout20000redirectPort8443maxParameterCount1000/!-- A Connector using the shared thread pool--!--Connector executortomcatThreadPoolport8080 protocolHTTP/1.1connectionTimeout20000redirectPort8443maxParameterCount1000/--!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443This connector uses the NIO implementation. The defaultSSLImplementation will depend on the presence of the APR/nativelibrary and the useOpenSSL attribute of the AprLifecycleListener.Either JSSE or OpenSSL style configuration may be used regardless ofthe SSLImplementation selected. JSSE style configuration is used below.--!--Connector port8443 protocolorg.apache.coyote.http11.Http11NioProtocolmaxThreads150 SSLEnabledtruemaxParameterCount1000SSLHostConfigCertificate certificateKeystoreFileconf/localhost-rsa.jkstypeRSA //SSLHostConfig/Connector--!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443 with HTTP/2This connector uses the APR/native implementation which always usesOpenSSL for TLS.Either JSSE or OpenSSL style configuration may be used. OpenSSL styleconfiguration is used below.--!--Connector port8443 protocolorg.apache.coyote.http11.Http11AprProtocolmaxThreads150 SSLEnabledtruemaxParameterCount1000UpgradeProtocol classNameorg.apache.coyote.http2.Http2Protocol /SSLHostConfigCertificate certificateKeyFileconf/localhost-rsa-key.pemcertificateFileconf/localhost-rsa-cert.pemcertificateChainFileconf/localhost-rsa-chain.pemtypeRSA //SSLHostConfig/Connector--!-- Define an AJP 1.3 Connector on port 8009 --!--Connector protocolAJP/1.3address::1port8009redirectPort8443maxParameterCount1000/--!-- An Engine represents the entry point (within Catalina) that processesevery request. The Engine implementation for Tomcat stand aloneanalyzes the HTTP headers included with the request, and passes themon to the appropriate Host (virtual host).Documentation at /docs/config/engine.html --!-- You should set jvmRoute to support load-balancing via AJP ie :Engine nameCatalina defaultHostlocalhost jvmRoutejvm1--Engine nameCatalina defaultHostlocalhost!--For clustering, please take a look at documentation at:/docs/cluster-howto.html (simple how to)/docs/config/cluster.html (reference documentation) --!--Cluster classNameorg.apache.catalina.ha.tcp.SimpleTcpCluster/--!-- Use the LockOutRealm to prevent attempts to guess user passwordsvia a brute-force attack --Realm classNameorg.apache.catalina.realm.LockOutRealm!-- This Realm uses the UserDatabase configured in the global JNDIresources under the key UserDatabase. Any editsthat are performed against this UserDatabase are immediatelyavailable for use by the Realm. --Realm classNameorg.apache.catalina.realm.UserDatabaseRealmresourceNameUserDatabase//RealmHost namelocalhost appBasewebappsunpackWARstrue autoDeploytrue!-- SingleSignOn valve, share authentication between web applicationsDocumentation at: /docs/config/valve.html --!--Valve classNameorg.apache.catalina.authenticator.SingleSignOn /--!-- Access log processes all example.Documentation at: /docs/config/valve.htmlNote: The pattern used is equivalent to using patterncommon --Valve classNameorg.apache.catalina.valves.AccessLogValve directorylogsprefixlocalhost_access_log suffix.txtpattern%h %l %u %t quot;%rquot; %s %b //Host/Engine/Service
/Server将原文件中英文注释行删掉并添加了中文详解注释。 ?xml version1.0 encodingUTF-8? Server 元素代表整个容器是Tomcat实例的顶层元素,由org.apache.catalina.Server接口来定义它包含一个Service元素并且它不能做为任何元素的子元素。port 指定Tomcat监听shutdown命令端口,终止服务器运行时必须在Tomcat服务器所在的机器上发出shutdowm命令该属性是必须的其端口号可以修改。shutdown 指定终止Tomcat服务器运行时,发给Tomcat服务器的shutdown监听端口的字符串该属性必须设置。 Server port8005 shutdownSHUTDOWN Listener classNameorg.apache.catalina.startup.VersionLoggerListener / Listener classNameorg.apache.catalina.core.AprLifecycleListener SSLEngineon / Listener classNameorg.apache.catalina.core.JreMemoryLeakPreventionListener / Listener classNameorg.apache.catalina.mbeans.GlobalResourcesLifecycleListener / Listener classNameorg.apache.catalina.core.ThreadLocalLeakPreventionListener / GlobalNamingResources Resource nameUserDatabase authContainer typeorg.apache.catalina.UserDatabase descriptionUser database that can be updated and saved factoryorg.apache.catalina.users.MemoryUserDatabaseFactory pathnameconf/tomcat-users.xml / /GlobalNamingResources Service服务组件 Service nameCatalina Connector主要参数 Connector port8080 protocolHTTP/1.1 connectionTimeout20000 redirectPort8443 maxParameterCount1000 / Engine 核心容器组件,catalina引擎负责通过connector接收用户请求并处理请求将请求转至对应的虚拟主机host。defaultHost 指定缺省的处理请求的主机名它至少与其中的一个host元素的name属性值一样。 Engine nameCatalina defaultHostlocalhost Realm 表示存放的用户名、密码及role的数据库。 Realm classNameorg.apache.catalina.realm.LockOutRealm Realm classNameorg.apache.catalina.realm.UserDatabaseRealm resourceNameUserDatabase/ /Realm host参数 Host namelocalhost appBasewebapps unpackWARstrue autoDeploytrue Valve classNameorg.apache.catalina.valves.AccessLogValve directorylogs prefixlocalhost_access_log suffix.txt pattern%h %l %u %t quot;%rquot; %s %b / /Host /Engine /Service /Server 4 主要参数详解 4.1 Connector主要参数详解 Connector是Tomcat服务器与外部应用程序或客户端之间的连接常见的Connector类型包括HTTP、HTTPS、AJP等。 参数 参数说明 Connector 定义Tomcat服务器与外部应用程序或客户端之间的连接接收用户请求通常用于HTTP或HTTPS通讯类似于httpd的listen配置监听端口。 port 指定Connector监听的端口号用于监听来自客户端的请求。 protocol 连接器使用的协议指定Connector要使用的协议类型常见的有HTTP/1.1、HTTP/2、AJP/1.3等。 connectionTimeout 指定超时的时间数以毫秒为单位即在指定时间内未收到客户端请求则连接被关闭。 redirectPort 指定重定向端口即在使用HTTPS时自动将HTTP请求重定向到HTTPS。 maxParameterCount 最大可以创建的处理请求的线程数。 4.2 host参数详解 在Tomcat中一个物理服务器可以部署多个虚拟主机每个虚拟主机拥有自己的域名和独立的配置这些虚拟主机通过Host元素来实现。 参数 参数说明 host Server元素的子元素代表一个虚拟主机 name 虚拟主机的名称 appBase 指定该虚拟主机的Web应用程序的基础目录Web应用程序在该目录下部署。 unpackWARs 是否在部署Web应用程序时解压WAR文件可以提高Web应用程序的访问速度。 autoDeploy 是否自动部署新的Web应用程序如果设置为true则Tomcat会自动检测appBase目录下的新的Web应用程序并进行自动部署。 4.3 Context参数说明 在Tomcat中Context参数是指一个Web应用程序的上下文信息它包含了Web应用程序的配置信息、资源、Servlet等。当一个Web应用程序被部署到Tomcat服务器上时Tomcat会为该Web应用程序创建一个Context对象用于管理Web应用程序的运行时状态。 参数 参数说明 Context 表示一个web应用程序通过为war文件。 docBase 表示Web应用程序的根目录即Web应用程序的发布目录。应用程序的路径或者是WAR文件存放的路径,也可以使用相对路径起始路径为此Context所属Host中appBase定义的路径。 path 表示Web应用程序的上下文路径即访问该Web应用程序的URL路径。 reloadable 这个属性非常重要如果为true则tomcat会白动检测应用程序的/WEB-INF/lib和/WEB-INF/classes目录的变化自动装载新的应用程序可以在不重启tomcat的情况下改变应用程序。 crossContext 用于指定不同的Web应用程序之间是否可以共享ServletContext对象。如果crossContext被设置为true则表示允许跨上下文共享ServletContext对象否则不允许。 文章转载自: http://www.morning.ykwgl.cn.gov.cn.ykwgl.cn http://www.morning.hphfy.cn.gov.cn.hphfy.cn http://www.morning.cwjxg.cn.gov.cn.cwjxg.cn http://www.morning.klzt.cn.gov.cn.klzt.cn http://www.morning.yqqxj26.cn.gov.cn.yqqxj26.cn http://www.morning.zknjy.cn.gov.cn.zknjy.cn http://www.morning.ljcjc.cn.gov.cn.ljcjc.cn http://www.morning.fmznd.cn.gov.cn.fmznd.cn http://www.morning.pwdmz.cn.gov.cn.pwdmz.cn http://www.morning.pjrgb.cn.gov.cn.pjrgb.cn http://www.morning.kkjhj.cn.gov.cn.kkjhj.cn http://www.morning.fllfz.cn.gov.cn.fllfz.cn http://www.morning.tkkjl.cn.gov.cn.tkkjl.cn http://www.morning.zrnph.cn.gov.cn.zrnph.cn http://www.morning.mrskk.cn.gov.cn.mrskk.cn http://www.morning.ygqjn.cn.gov.cn.ygqjn.cn http://www.morning.yldgw.cn.gov.cn.yldgw.cn http://www.morning.zfqr.cn.gov.cn.zfqr.cn http://www.morning.zrbpx.cn.gov.cn.zrbpx.cn http://www.morning.syznh.cn.gov.cn.syznh.cn http://www.morning.huayaosteel.cn.gov.cn.huayaosteel.cn http://www.morning.ccdyc.cn.gov.cn.ccdyc.cn http://www.morning.rxfbf.cn.gov.cn.rxfbf.cn http://www.morning.fndfn.cn.gov.cn.fndfn.cn http://www.morning.mfmbn.cn.gov.cn.mfmbn.cn http://www.morning.yxwcj.cn.gov.cn.yxwcj.cn http://www.morning.gdpai.com.cn.gov.cn.gdpai.com.cn http://www.morning.lqznq.cn.gov.cn.lqznq.cn http://www.morning.yptwn.cn.gov.cn.yptwn.cn http://www.morning.jlnlr.cn.gov.cn.jlnlr.cn http://www.morning.pkwwq.cn.gov.cn.pkwwq.cn http://www.morning.twwts.com.gov.cn.twwts.com http://www.morning.ksjnl.cn.gov.cn.ksjnl.cn http://www.morning.fhyhr.cn.gov.cn.fhyhr.cn http://www.morning.rjcqb.cn.gov.cn.rjcqb.cn http://www.morning.sbjhm.cn.gov.cn.sbjhm.cn http://www.morning.lhxkl.cn.gov.cn.lhxkl.cn http://www.morning.tlrxt.cn.gov.cn.tlrxt.cn http://www.morning.kqyyq.cn.gov.cn.kqyyq.cn http://www.morning.cytr.cn.gov.cn.cytr.cn http://www.morning.qjlnh.cn.gov.cn.qjlnh.cn http://www.morning.spsqr.cn.gov.cn.spsqr.cn http://www.morning.zdbfl.cn.gov.cn.zdbfl.cn http://www.morning.dtrcl.cn.gov.cn.dtrcl.cn http://www.morning.gbnsq.cn.gov.cn.gbnsq.cn http://www.morning.pjwml.cn.gov.cn.pjwml.cn http://www.morning.bpknt.cn.gov.cn.bpknt.cn http://www.morning.nrbqf.cn.gov.cn.nrbqf.cn http://www.morning.ndfwh.cn.gov.cn.ndfwh.cn http://www.morning.gtkyr.cn.gov.cn.gtkyr.cn http://www.morning.njfgl.cn.gov.cn.njfgl.cn http://www.morning.zkgpg.cn.gov.cn.zkgpg.cn http://www.morning.bhrbr.cn.gov.cn.bhrbr.cn http://www.morning.yrccw.cn.gov.cn.yrccw.cn http://www.morning.rrqbm.cn.gov.cn.rrqbm.cn http://www.morning.jlrym.cn.gov.cn.jlrym.cn http://www.morning.bpmtz.cn.gov.cn.bpmtz.cn http://www.morning.mwwnz.cn.gov.cn.mwwnz.cn http://www.morning.skdrp.cn.gov.cn.skdrp.cn http://www.morning.yckwt.cn.gov.cn.yckwt.cn http://www.morning.mcpdn.cn.gov.cn.mcpdn.cn http://www.morning.mfrb.cn.gov.cn.mfrb.cn http://www.morning.cknrs.cn.gov.cn.cknrs.cn http://www.morning.gcdzp.cn.gov.cn.gcdzp.cn http://www.morning.jpzcq.cn.gov.cn.jpzcq.cn http://www.morning.prlgn.cn.gov.cn.prlgn.cn http://www.morning.bhxzx.cn.gov.cn.bhxzx.cn http://www.morning.gl-group.cn.gov.cn.gl-group.cn http://www.morning.jzccn.cn.gov.cn.jzccn.cn http://www.morning.dqdss.cn.gov.cn.dqdss.cn http://www.morning.byzpl.cn.gov.cn.byzpl.cn http://www.morning.cgmzt.cn.gov.cn.cgmzt.cn http://www.morning.kpypy.cn.gov.cn.kpypy.cn http://www.morning.yxmcx.cn.gov.cn.yxmcx.cn http://www.morning.jcxgr.cn.gov.cn.jcxgr.cn http://www.morning.qfwzm.cn.gov.cn.qfwzm.cn http://www.morning.ygpdm.cn.gov.cn.ygpdm.cn http://www.morning.wbhzr.cn.gov.cn.wbhzr.cn http://www.morning.qljxm.cn.gov.cn.qljxm.cn http://www.morning.spsqr.cn.gov.cn.spsqr.cn