server.xml引入子文件配置(tomcat虚拟主机)

在配置tomcat虚拟主机时候,如何每一个虚拟主机写成单独文件,server.xml包含这些子文件? 如以下《OneinStack》中,添加JAVA环境虚拟主机后tomcat配置文件详情:

/usr/local/tomcat/conf/server.xml

  1. xml version="1.0" encoding="UTF-8"?>
  2. >
  3. >
  4. >
  5. ]>
  6. <Server port="8006" shutdown="SHUTDOWN">
  7.   <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
  8.   <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
  9.   <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>
  10.   <Listener className="org.apache.catalina.core.AprLifecycleListener"/>
  11.   <GlobalNamingResources>
  12.     <Resource name="UserDatabase" auth="Container"
  13.               type="org.apache.catalina.UserDatabase"
  14.               description="User database that can be updated and saved"
  15.               factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
  16.               pathname="conf/tomcat-users.xml" />
  17.   GlobalNamingResources>
  18.   <Service name="Catalina">
  19.     <Connector port="8080"
  20.               protocol="org.apache.coyote.http11.Http11AprProtocol"
  21.               connectionTimeout="20000"
  22.               redirectPort="8443"
  23.               maxThreads="1000"
  24.               minSpareThreads="20"
  25.               acceptCount="1000"
  26.               debug="0"
  27.               disableUploadTimeout="true"
  28.               useBodyEncodingForURI="true"
  29.               enableLookups="false"
  30.               URIEncoding="UTF-8" />
  31.     <Engine name="Catalina" defaultHost="localhost">
  32.       <Realm className="org.apache.catalina.realm.LockOutRealm">
  33.         <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
  34.                resourceName="UserDatabase"/>
  35.       Realm>
  36.       &localhost-vhost;
  37.       &java.linuxeye.com-vhost;
  38.       &demo.linuxeye.com-vhost;
  39.     Engine>
  40.   Service>
  41. Server>

注:在元素前添加如下格式:

  1.   >
  2. ]>

并在...注:不能以数字开头)即可。

下面是每个单独虚拟主机文件:/usr/local/tomcat/conf/vhost/localhost.xml

  1. <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
  2.   <Context path="" docBase="/data/wwwroot/default" debug="0" reloadable="true" crossContext="true"/>
  3.   <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
  4.          prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t "%r" %s %b" />

/usr/local/tomcat/conf/vhost/demo.linuxeye.com.xml

  1. <Host name="demo.linuxeye.com" appBase="webapps" unpackWARs="true" autoDeploy="true">
  2.   <Context path="" docBase="/data/wwwroot/demo.linuxeye.com" debug="0" reloadable="true" crossContext="true"/>
  3.   <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
  4.          prefix="demo.linuxeye.com_access_log." suffix=".txt" pattern="%h %l %u %t "%r" %s %b" />

/usr/local/tomcat/conf/vhost/java.linuxeye.com.xml

  1. <Host name="java.linuxeye.com" appBase="webapps" unpackWARs="true" autoDeploy="true"> <Alias>java1.linuxeye.comAlias>
  2.   <Context path="" docBase="/data/wwwroot/java.linuxeye.com" debug="0" reloadable="true" crossContext="true"/>
  3.   <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
  4.          prefix="java.linuxeye.com_access_log." suffix=".txt" pattern="%h %l %u %t "%r" %s %b" />
  5. Host>
Wed Sep  2 14:06:44 CST 2015
发布于 2025-02-15 17:04:30
分享
海报
190
上一篇:制作PHP的RPM包教程 下一篇:Tomcat日志切割(logrotate)
目录

    忘记密码?

    图形验证码