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:指定一個(gè)端口,這個(gè)端口負(fù)責(zé)監(jiān)聽關(guān)閉tomcat的請(qǐng)求

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

          3service name:指定service的名字

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

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

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

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

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

          redirectPort:指定服務(wù)器正在處理http請(qǐng)求時(shí)收到了一個(gè)SSL傳輸請(qǐng)求后重定向的端口號(hào)

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

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

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

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

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

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

          name:指定主機(jī)名

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

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

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

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

          prefix:指定log文件的前綴

          suffix:指定log文件的后綴

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

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

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

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

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

          pattern 有兩個(gè)值,common方式記錄遠(yuǎn)程主機(jī)名或ip地址,用戶名,日期,第一行請(qǐng)求的字符串,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.
          -->
          <!-- 一個(gè)“Server”是一個(gè)提供完整的JVM的獨(dú)立組件,它可以包含一個(gè)或多個(gè)
                “Service”實(shí)例。服務(wù)器在指定的端口上監(jiān)聽shutdown命令。
              
                注意:一個(gè)“Server”自身不是一個(gè)“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.
              -->
             <!-- 一個(gè)“Service”是一個(gè)或多個(gè)共用一個(gè)單獨(dú)“Container”(容器)的“Connectors”
                  組合(因此,應(yīng)用程序在容器中可見)。通常,這個(gè)容器是一個(gè)“Engine”
                  (引擎),但這不是必須的。
                
                  注意:一個(gè)“Service”自身不是一個(gè)容器,因此,在這個(gè)級(jí)別上你不可定義
                  諸如“Valves”或“Loggers”子組件。
             -->

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

          <2025年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          導(dǎo)航

          留言簿(6)

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評(píng)論

          閱讀排行榜

          主站蜘蛛池模板: 霍林郭勒市| 石台县| 沧州市| 黄石市| 六枝特区| 北辰区| 九寨沟县| 东丰县| 盐源县| 静海县| 屏南县| 丹棱县| 顺平县| 瑞昌市| 五峰| 周宁县| 永州市| 蒙山县| 东莞市| 白水县| 贵德县| 库尔勒市| 阿克| 大荔县| 济源市| 湘潭市| 莆田市| 福贡县| 萍乡市| 西藏| 凤山县| 乾安县| 舟曲县| 丰都县| 延寿县| 延安市| 临桂县| 尼玛县| 曲沃县| 濮阳县| 清远市|