First read this http://tomcat.apache.org/tomcat-7.0-doc/config/host.html

If you want tomcat to accept requests for different hosts e.g., www.myhostname.com then you must

0. create ${catalina.base}/www/appBase , ${catalina.base}/www/deploy, and ${catalina.base}/conf/Catalina/www.myhostname.com

  1. add a host entry in the server.xml file
  <Host appBase="www/appBase" name="www.myhostname.com"/>

2. Create the the following file under conf/Catalina/www.myhostname.com/ROOT.xml

<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="${catalina.base}/www/deploy/mywebapp.war">
</Context>

Add any parameters specific to this hosts webapp to this context file

3. put your war file in ${catalina.base}/www/deploy

When tomcat starts, it finds the host entry, then looks for any context files and will start any apps with a context.

To add more sites just repeat and rinse, all webapps can share the same war file location and appbase. 

  • No labels