Tomcat multi site configuration details and implementation methods

  • 2020-05-30 21:20:46
  • OfStack

Tomcat multi-site configuration

Today, I tried the multi-site configuration of Tomcat on a whim, all of which were completed by modifying server.xml, and other methods are not introduced

1 species:

This is the most common, on the Internet 1 search can be found, here or take out to say 1, convenient to do a comparison, directly posted code

<Host name="localhost" appBase="www" 
      unpackWARs="true" autoDeploy="true"> 
    <!-- SingleSignOn valve, share authentication between web applications 
       Documentation at: /docs/config/valve.html --> 
    <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> 
    <!-- Access log processes all example. 
       Documentation at: /docs/config/valve.html 
       Note: The pattern used is equivalent to using pattern="common" --> 
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" 
        prefix="localhost_access_log." suffix=".txt" 
        pattern="%h %l %u %t "%r" %s %b" /> 
    <Context docBase="F:\lc\projects\test1\WebRoot" path="/test1" /> 
    <Context docBase="F:\lc\projects\test2\WebRoot" path="/test2" /> 

By accessing http: / / localhost: 8080 / test1 with http: / / localhost: 8080 / test2 to visit each of these two applications of the most common

2 kinds of

Different applications can be accessed through different ip, and the application name can be added after IP, such as or http:// The specific configuration is as follows:

<span style="white-space:pre"> </span><Host name=""> 
    <Context path="" docBase="F:\lc\soft\apache-tomcat-7.0.22\webapps\docs" /> 
   <Host name=""> 
    <Context path="" docBase="F:\lc\soft\apache-tomcat-7.0.22\webapps\examples" /> 

Note that, if configured in the second way, the Tomcat default Host tags need to be deleted and commented, because the default host intercepts all native IP such as,

All use in testing requires the default host to be removed or commented

If you don't like the ip address plus 8080, you can search for the 8080 keyword in this file, replace it with 80, and then use it accessible..

Thank you for reading, I hope to help you, thank you for your support of this site!

Related articles: