Tomcat中server.xml配置介紹
<Server port="8005" shutdown="SHUTDOWN" debug="0">
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
debug="0"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
debug="0"/>
<GlobalNamingResources>
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved">
</Resource>
<ResourceParams name="UserDatabase">
<parameter>
<name>factory</name>
<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
</parameter>
<parameter>
<name>pathname</name>
<value>conf/tomcat-users.xml</value>
</parameter>
</ResourceParams>
</GlobalNamingResources>
<Service name="Tomcat-Standalone">
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8080" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="100" debug="0" connectionTimeout="20000"
useURIValidationHack="false" disableUploadTimeout="true" />
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8009" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="10" debug="0" connectionTimeout="20000"
useURIValidationHack="false"
protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>
<Engine name="Standalone" defaultHost="localhost" debug="0">
<!--
<Valve className="org.apache.catalina.valves.RequestDumperValve"/>
-->
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="catalina_log." suffix=".txt"
timestamp="true"/>
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
debug="0" resourceName="UserDatabase"/>
<Host name="localhost" debug="0" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="localhost_log." suffix=".txt"
timestamp="true"/>
<Context path="/gdqy" reloadable="true" docBase="D:/gdqy/ept" debug="0"
crossContext="true"/>
</Host>
</Engine>
</Service>
</Server>
1、server port:指定一個端口,這個端口負責監聽關閉tomcat的請求
2、shut down:指定向端口發送的命令字符串
3、service name:指定service的名字
4、Connector:(表示客戶端和service之間的連接)
port 指定服務器端要創建的端口號,并在這個斷口監聽來自客戶端的請求
minProcessors:服務器啟動時創建的處理請求的線程數
maxProcessors:最大可以創建的處理請求的線程數
enableLookups:如果為true,則可以通過調用request.getRemoteHost()進行DNS查詢來得到遠程客戶端的實際主機名,若為false則不進行DNS查詢,而是返回其ip地址
redirectPort:指定服務器正在處理http請求時收到了一個SSL傳輸請求后重定向的端口號
acceptCount 指定當所有可以使用的處理請求的線程數都被使用時,可以放到處理隊列中的請求數,超過這個數的請求將不予處理
connectionTimeout 指定超時的時間數(以毫秒為單位)
5、Engine:(表示指定service中的請求處理機,接收和處理來自Connector的請求)
defaultHost:指定缺省的處理請求的主機名,它至少與其中的一個host元素的name屬性值是一樣的
6、Context:(表示一個web應用程序,通常為WAR文件,關于WAR的具體信息見servlet規范) docBase 應用程序的路徑或者是WAR文件存放的路徑
path:表示此web應用程序的url的前綴,這樣請求的url為http://localhost:8080/path/****
reloadable:這個屬性非常重要,如果為true,則tomcat會自動檢測應用程序的/WEB-INF/lib 和/WEB-INF/classes目錄的變化,自動裝載新的應用程序,我們可以在不重起tomcat的情況下改變應用程序
7、host:(表示一個虛擬主機)
name:指定主機名
appBase:應用程序基本目錄,即存放應用程序的目錄
unpackWARs:如果為true,則tomcat會自動將WAR文件解壓,否則不解壓,直接從WAR文件中運行應用程序
8、Logger:(表示日志,調試和錯誤信息)
className 指定logger使用的類名,此類必須實現org.apache.catalina.Logger 接口
prefix:指定log文件的前綴
suffix:指定log文件的后綴
timestamp:如果為true,則log文件名中要加入時間,如下例:localhost_log.
9、Realm:(表示存放用戶名,密碼及role的數據庫)
className:指定Realm使用的類名,此類必須實現org.apache.catalina.Realm接口
10、Valve:(功能與Logger差不多,其prefix和suffix屬性解釋和Logger 中的一樣)
className:指定Valve使用的類名,如用org.apache.catalina.valves.AccessLogValve類可以記錄應用程序的訪問信息
11、directory:指定log文件存放的位置
pattern 有兩個值,common方式記錄遠程主機名或ip地址,用戶名,日期,第一行請求的字符串,HTTP響應代碼,發送的字節數。combined方式比common方式記錄的值更多。
另附tomcat5中server.xml配置
<!-- Example Server Configuration File -->
<!-- Tomcat服務器配置示例文件 -->
<!-- Note that component elements are nested corresponding to their
parent-child relationships with each other -->
<!-- 注意,這些組件的構成是根據相互之間的父子關系進行嵌套的。-->
<!-- A "Server" is a singleton element that represents the entire JVM,
which may contain one or more "Service" instances. The Server
listens for a shutdown command on the indicated port.
Note: A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" or "Loggers" at this level.
-->
<!-- 一個“Server”是一個提供完整的JVM的獨立組件,它可以包含一個或多個
“Service”實例。服務器在指定的端口上監聽shutdown命令。
注意:一個“Server”自身不是一個“Container”(容器),因此在這里你
不可以定義諸如“Valves”或者“Loggers”子組件
-->
<Server port="8005" shutdown="SHUTDOWN" debug="0">
<!-- Comment these entries out to disable JMX MBeans support -->
<!-- 這些指令組件關閉JMX MBeans支持 -->
<!-- You may also configure custom components (e.g. Valves/Realms) by
including your own mbean-descriptor file(s), and setting the
"descriptors" attribute to point to a ';' seperated list of paths
(in the ClassLoader sense) of files to add to the default list.
e.g. descriptors="/com/myfirm/mypackage/mbean-descriptor.xml"
-->
<!-- 你也可以通過包含你自己的mbean描述文件配置自定義的組件,然后設置
“descriptors”屬性為以“;”為分隔的文件名列表嚴將它添加到默認列表
中,例如:descriptors="/com/myfirm/mypackage/mbean-descriptor.xml"。
-->
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
debug="0"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
debug="0"/>
<!-- Global JNDI resources -->
<!-- 全局JNDI資源 -->
<GlobalNamingResources>
<!-- Test entry for demonstration purposes -->
<!-- 出于示例目的的測試入口 -->
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users -->
<!-- 可編輯的,用來通過UserDatabaseRealm認證用戶的用戶數據庫 -->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved">
</Resource>
<ResourceParams name="UserDatabase">
<parameter>
<name>factory</name>
<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
</parameter>
<parameter>
<name>pathname</name>
<value>conf/tomcat-users.xml</value>
</parameter>
</ResourceParams>
</GlobalNamingResources>
<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" (and therefore the web applications visible
within that Container). Normally, that Container is an "Engine",
but this is not required.
Note: A "Service" is not itself a "Container", so you may not
define subcomponents such as "Valves" or "Loggers" at this level.
-->
<!-- 一個“Service”是一個或多個共用一個單獨“Container”(容器)的“Connectors”
組合(因此,應用程序在容器中可見)。通常,這個容器是一個“Engine”
(引擎),但這不是必須的。
注意:一個“Service”自身不是一個容器,因此,在這個級別上你不可定義
諸如“Valves”或“Loggers”子組件。
-->
posted on 2008-12-23 11:21 丁克設計 閱讀(572) 評論(0) 編輯 收藏 所屬分類: Tomcat 技術文檔