server.xml引入子文件配置(tomcat虛擬主機)

在配置tomcat虛擬主機時候,如何每個虛擬主機寫成單獨文件,server.xml包含這些子文件? 如如下《OneinStack》中,添加JAVA環境虛擬主機後tomcat配置文件詳情:java

/usr/local/tomcat/conf/server.xmllinux

 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE server-xml [
<!ENTITY localhost-vhost SYSTEM "file:///usr/local/tomcat/conf/vhost/localhost.xml">
<!ENTITY java.linuxeye.com-vhost SYSTEM "file:///usr/local/tomcat/conf/vhost/java.linuxeye.com.xml">
<!ENTITY demo.linuxeye.com-vhost SYSTEM "file:///usr/local/tomcat/conf/vhost/demo.linuxeye.com.xml">
]>
<Server port="8006" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>
  <Listener className="org.apache.catalina.core.AprLifecycleListener"/>
<!--
  <Listener className="org.apache.catalina.mbeans.JmxRemoteLifecycleListener" rmiRegistryPortPlatform="8081" rmiServerPortPlatform="8082" />
-->
  <GlobalNamingResources>
    <Resource name="UserDatabase" auth="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="8080"
              protocol="org.apache.coyote.http11.Http11AprProtocol"
              connectionTimeout="20000"
              redirectPort="8443"
              maxThreads="1000"
              minSpareThreads="20"
              acceptCount="1000"
              debug="0"
              disableUploadTimeout="true"
              useBodyEncodingForURI="true"
              enableLookups="false"
              URIEncoding="UTF-8" />
    <Engine name="Catalina" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>
      &localhost-vhost;
      &java.linuxeye.com-vhost;
      &demo.linuxeye.com-vhost;
    </Engine>
  </Service>
</Server>
注:在<server>元素前添加以下格式:web

 
<!DOCTYPE server-xml [
  <!ENTITY localhost-vhost SYSTEM "file:///usr/local/tomcat/conf/vhost/localhost.xml">
]>
並在<Engine>...</Engine]引用它(localhost-vhost,注:不能以數字開頭)便可。apache

下面是每一個單獨虛擬主機文件:/usr/local/tomcat/conf/vhost/localhost.xmltomcat

 
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
  <Context path="" docBase="/data/wwwroot/default" debug="0" reloadable="true" crossContext="true"/>
  <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
         prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
/usr/local/tomcat/conf/vhost/demo.linuxeye.com.xmlapp

 
<Host name="demo.linuxeye.com" appBase="webapps" unpackWARs="true" autoDeploy="true">
  <Context path="" docBase="/data/wwwroot/demo.linuxeye.com" debug="0" reloadable="true" crossContext="true"/>
  <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
         prefix="demo.linuxeye.com_access_log." suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
/usr/local/tomcat/conf/vhost/java.linuxeye.com.xmlwebapp

 
<Host name="java.linuxeye.com" appBase="webapps" unpackWARs="true" autoDeploy="true"> <Alias>java1.linuxeye.com</Alias>
  <Context path="" docBase="/data/wwwroot/java.linuxeye.com" debug="0" reloadable="true" crossContext="true"/>
  <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
         prefix="java.linuxeye.com_access_log." suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
</Host>
---------------------
做者:jimaoa
原文:https://blog.csdn.net/jimaoa/article/details/84773386
版權聲明:本文爲博主原創文章,轉載請附上博文連接!.net

相關文章
相關標籤/搜索