VDS Sphera Knowledge Base

Main / Browse Categories / Tomcat Server / How can I configure Tomcat with multiple virtual hosts?

Print article Print Article    Email article Email Article

How can I configure Tomcat with multiple virtual hosts?
Highly recommended tutorial:
http://www.csse.uwa.edu.au/~ryan/tech/tomcat.html

Example "/etc/tomcat4/server.xml" file:

<Host name="domain1.com" debug="0" appBase="webapps" unpackWARs="true">
<Alias>www.domain1.com</Alias>
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="virtual_log1." suffix=".log" timestamp="true"/>
<Context path="" docBase="/var/tomcat4/webapps/domain1" debug="0" reloadable="true"/>
</Host>

<Host name="domain2.com" debug="0" appBase="webapps" unpackWARs="true">
<Alias>www.domain2.com</Alias>
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="virtual_log2." suffix=".log" timestamp="true"/>
<Context path="" docBase="/var/tomcat4/webapps/domain2" debug="0" reloadable="true"/>
</Host>

Example "/etc/httpd/conf/mod_jk.conf" file:

<IfModule mod_jk.c>
     JkWorkersFile conf/workers.properties
#    JkLogFile logs/mod_jk.log
#    JkLogLevel info
 
    JkMount /*.jsp ajp13
    JkMount /hw/* ajp13
#    JkMount /examples/* worker1
#    JkMount /*/servlet/ worker1
#    JkMount /webdav/* worker1
#    JkMount /tomcat-docs/* worker1
#    JkMount /admin/* ajp13
#    JkMount /manager/* worker1
 
#    JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
#    JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
#    JkRequestLogFormat "%w %V %T"
#    JkOptions +ForwardURICompat
<VirtualHost *>
    ServerName domain1.com
    ServerAlias www.domain1.com
    DocumentRoot /var/tomcat4/webapps/domain1
    JkMount /* ajp13
</VirtualHost>
<VirtualHost *>
    ServerName domain2.com
    ServerAlias www.domain2.com
    DocumentRoot /var/tomcat4/webapps/domain2
    JkMount /* ajp13
</VirtualHost>
</IfModule>

User Comments
How can I configure Tomcat with multiple virtual hosts?  
There are no user comments for this topic.
 

Attachments
No attachments.

Related Articles
 How come my catalina.out file is zero length?
 Where do I put my JSP and servlet files?
 Where is my mod_jk.conf file?
 Where are my Tomcat logs located?
 What version of Tomcat will I have?

Why Choose Our Hosting?

Continue reading »

Featured Hosting Plan


Learn more about our VPS Extreme

What is Included?

  • PHP 5/MySQL 5
  • Plesk Control Panel
  • Unique IP Address
  • SAS Hardware Raid diskspace
  • CentOS 5 x86_64 bit
  • Multi-homed Tier 1 Bandwidth
  • Full Upgrade capabilities
Continue reading »