kavin

Tomcat配置文件详解

kavin Tomcat 2018-05-05 3208浏览 0


Tomcat的配置文件默认存放在/usr/local/tomcat/conf目录中,主要有以下几个

 

[root@localhost conf]# ls

catalina.policy      context.xml         server.xml        web.xml

catalina.properties  logging.properties  tomcat-users.xml

server.xml: Tomcat的主配置文件,包含Service, Connector, Engine, Realm, Valve, Hosts主组件的相关配置信息;

 

web.xml:遵循Servlet规范标准的配置文件,用于配置servlet,并为所有的Web应用程序提供包括MIME映射等默认配置信息;

 

tomcat-user.xmlRealm认证时用到的相关角色、用户和密码等信息;Tomcat自带的manager默认情况下会用到此文件;在Tomcat中添加/删除用户,为用户指定角色等将通过编辑此文件实现;

 

catalina.policyJava相关的安全策略配置文件,在系统资源级别上提供访问控制的能力;

 

catalina.propertiesTomcat内部package的定义及访问相关的控制,也包括对通过类装载器装载的内容的控制;Tomcat6在启动时会事先读取此文件的相关设置;

 

logging.properties: Tomcat6通过自己内部实现的JAVA日志记录器来记录操作相关的日志,此文件即为日志记录器相关的配置信息,可以用来定义日志记录的组件级别以及日志文件的存在位置等;

 

context.xml:所有host的默认配置信息;

 

 

1server.xml

Tomcat以面向对象的方式运行,它可以在运行时动态加载配置文件中定义的对象结构,这有点类似于apachehttpd模块的调用方式。server.xml中定义的每个主元素都会被创建为对象,并以某特定的层次结构将这些对象组织在一起。下面是个样样例配置:

 

 

<Server port=8005shutdown=SHUTDOWN>

 

  <Listener className=org.apache.catalina.core.Jas<a href="http://www.94ip.com/perl/" title="perl"target="_blank">perL</a>istener/>

  <Listener className=org.apache.catalina.mbeans.ServerLifecycleListener/>

  <Listener className=org.apache.catalina.mbeans.GlobalResourcesLifecycleListener/>

 

  <GlobalNamingResources>

   <Resource name=UserDatabaseauth=Container

   type=org.apache.catalina.UserDatabase

   description=User database that can be updated and saved

   factory=org.apache.catalina.users.MemoryUserDatabaseFactory

   pathname=conf/tomcat-users.xml/>

  </GlobalNamingResources>

 

  <Service name=Catalina>

 

    <Connector port=8080protocol=HTTP/1.1

      maxThreads=150connectionTimeout=20000

      redirectPort=8443/>

 

    <Engine name=CatalinadefaultHost=localhost>

 

      <Host name=localhostappBase=webapps

        unpackWARs=trueautoDeploy=true

        xmlValidation=falsexmlNamespaceAware=false>

      </Host>

    </Engine>

  </Service>

</Server>

 

<Server port=8005shutdown=SHUTDOWN>

  <Listener className=org.apache.catalina.core.AprLifecycleListenerSSLEngine=on/>

  <Listener className=org.apache.catalina.core.JasperListener/>

  <Listener className=org.apache.catalina.core.JreMemoryLeakPreventionListener/>

  <Listener className=org.apache.catalina.mbeans.GlobalResourcesLifecycleListener/>

  <Listener className=org.apache.catalina.core.ThreadLocalLeakPreventionListener/>

 

  <GlobalNamingResources>

    <Resource name=UserDatabaseauth=Container

      type=org.apache.catalina.UserDatabase

      description=User database that can be updated and saved

      factory=org.apache.catalina.users.MemoryUserDatabaseFactory

      pathname=conf/tomcat-users.xml/>

  </GlobalNamingResources>

 

  <Service name=Catalina>

 

    <Connector port=8080protocol=HTTP/1.1

      connectionTimeout=20000

      redirectPort=8443/>

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

 

    <Engine name=CatalinadefaultHost=localhost>

 

     <Realm className=org.apache.catalina.realm.LockOutRealm>

       <Realm className=org.apache.catalina.realm.UserDatabaseRealm

           resourceName=UserDatabase/>

     </Realm>

 

     <Host name=localhostappBase=webapps

         unpackWARs=trueautoDeploy=true>

 

       <Valve className=org.apache.catalina.valves.AccessLogValvedirectory=logs

           prefix=localhost_access_log.suffix=.txt

           pattern=%h %l %u %t "%r" %s %b/>

 

     </Host>

    </Engine>

  </Service>

</Server>

server.xml文件中可定义的元素非常多,包括Server, Service, Connector, Engine, Cluster, Host, Alias, Context, Realm, Valve, Manager, Listener, Resources, Resource, ResourceEnvRef, ResourceLink, WatchedResource, GlobalNameingResources, Store, Transaction, Channel, Membership, Transport, Member, ClusterListener等。


继续浏览有关 tomcat 的文章
发表评论