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>

          1server port:指定一個端口,這個端口負(fù)責(zé)監(jiān)聽關(guān)閉tomcat的請求

          2shut down:指定向端口發(fā)送的命令字符串

          3service name:指定service的名字

          4Connector(表示客戶端和service之間的連接)

          port 指定服務(wù)器端要創(chuàng)建的端口號,并在這個斷口監(jiān)聽來自客戶端的請求

          minProcessors:服務(wù)器啟動時創(chuàng)建的處理請求的線程數(shù)

          maxProcessors:最大可以創(chuàng)建的處理請求的線程數(shù)

          enableLookups:如果為true,則可以通過調(diào)用request.getRemoteHost()進(jìn)行DNS查詢來得到遠(yuǎn)程客戶端的實際主機(jī)名,若為false則不進(jìn)行DNS查詢,而是返回其ip地址

          redirectPort:指定服務(wù)器正在處理http請求時收到了一個SSL傳輸請求后重定向的端口號

          acceptCount 指定當(dāng)所有可以使用的處理請求的線程數(shù)都被使用時,可以放到處理隊列中的請求數(shù),超過這個數(shù)的請求將不予處理

          connectionTimeout 指定超時的時間數(shù)(以毫秒為單位)
          5
          Engine(表示指定service中的請求處理機(jī),接收和處理來自Connector的請求)

          defaultHost:指定缺省的處理請求的主機(jī)名,它至少與其中的一個host元素的name屬性值是一樣的
          6
          Context(表示一個web應(yīng)用程序,通常為WAR文件,關(guān)于WAR的具體信息見servlet規(guī)范) docBase 應(yīng)用程序的路徑或者是WAR文件存放的路徑

          path:表示此web應(yīng)用程序的url的前綴,這樣請求的urlhttp://localhost:8080/path/****

          reloadable:這個屬性非常重要,如果為true,則tomcat會自動檢測應(yīng)用程序的/WEB-INF/lib /WEB-INF/classes目錄的變化,自動裝載新的應(yīng)用程序,我們可以在不重起tomcat的情況下改變應(yīng)用程序

          7host(表示一個虛擬主機(jī))

          name:指定主機(jī)名

          appBase:應(yīng)用程序基本目錄,即存放應(yīng)用程序的目錄

          unpackWARs:如果為true,則tomcat會自動將WAR文件解壓,否則不解壓,直接從WAR文件中運行應(yīng)用程序

          8Logger(表示日志,調(diào)試和錯誤信息)

          className 指定logger使用的類名,此類必須實現(xiàn)org.apache.catalina.Logger 接口

          prefix:指定log文件的前綴

          suffix:指定log文件的后綴

          timestamp:如果為true,則log文件名中要加入時間,如下例:localhost_log.2001-10-04.txt
          9
          Realm(表示存放用戶名,密碼及role的數(shù)據(jù)庫)

          className:指定Realm使用的類名,此類必須實現(xiàn)org.apache.catalina.Realm接口

          10Valve(功能與Logger差不多,其prefixsuffix屬性解釋和Logger 中的一樣)

          className:指定Valve使用的類名,如用org.apache.catalina.valves.AccessLogValve類可以記錄應(yīng)用程序的訪問信息

          11
          directory:指定log文件存放的位置

          pattern 有兩個值,common方式記錄遠(yuǎn)程主機(jī)名或ip地址,用戶名,日期,第一行請求的字符串,HTTP響應(yīng)代碼,發(fā)送的字節(jié)數(shù)。combined方式比common方式記錄的值更多。

          另附tomcat5中server.xml配置

          <!-- Example Server Configuration File -->
          <!-- Tomcat服務(wù)器配置示例文件 -->

          <!-- Note that component elements are nested corresponding to their
                parent-child relationships with each other -->
          <!-- 注意,這些組件的構(gòu)成是根據(jù)相互之間的父子關(guān)系進(jìn)行嵌套的。-->

          <!-- 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”實例。服務(wù)器在指定的端口上監(jiān)聽shutdown命令。
              
                注意:一個“Server”自身不是一個“Container”(容器),因此在這里你
                不可以定義諸如“Valves”或者“Loggers”子組件
          -->

          <Server port="8005" shutdown="SHUTDOWN" debug="0">


             <!-- Comment these entries out to disable JMX MBeans support -->
             <!-- 這些指令組件關(guān)閉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描述文件配置自定義的組件,然后設(shè)置
                  “descriptors”屬性為以“;”為分隔的文件名列表嚴(yán)將它添加到默認(rèn)列表
                  中,例如: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認(rèn)證用戶的用戶數(shù)據(jù)庫 -->
             
               <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”
                  組合(因此,應(yīng)用程序在容器中可見)。通常,這個容器是一個“Engine”
                  (引擎),但這不是必須的。
                
                  注意:一個“Service”自身不是一個容器,因此,在這個級別上你不可定義
                  諸如“Valves”或“Loggers”子組件。
             -->

          posted on 2008-12-23 11:21 丁克設(shè)計 閱讀(574) 評論(0)  編輯  收藏 所屬分類: Tomcat 技術(shù)文檔

          <2025年5月>
          27282930123
          45678910
          11121314151617
          18192021222324
          25262728293031
          1234567

          導(dǎo)航

          留言簿(6)

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          主站蜘蛛池模板: 贵溪市| 革吉县| 垫江县| 大荔县| 六安市| 万宁市| 佛学| 翼城县| 洮南市| 宿迁市| 门头沟区| 原平市| 湟源县| 民县| 大宁县| 平远县| 庐江县| 桃园县| 绩溪县| 星座| 新蔡县| 黎平县| 锡林浩特市| 高尔夫| 上栗县| 化州市| 哈密市| 乌海市| 扶沟县| 涪陵区| 华阴市| 永年县| 津南区| 英吉沙县| 手游| 化德县| 宁河县| 若尔盖县| 镇雄县| 广昌县| 隆子县|