Tuesday, February 7, 2012

Hosting Multiple Domains On A Single Apache HTTPD / Tomcat Server Combination

This is a quick and easy guide on how to deploy multiple domains on a single Tomcat sever fronted by a single Apache HTTPD server. I am assuming you already have installed mod_jk and got the communication between Apache and Tomcat working.

First the Tomcat changes ( I am using Tomcat 7 but it should work the same in Tomcat 6 too). Edit server.xml file in conf directory and scroll down until you see the <Host> section there. Copy the host section and paste it again so you have two host sections and modify the name attributes to contain the two domain names. Also point appBase attributes to two different folders (create them under the Tomcat directory). You will deploy your apps to the ROOT folders under each appbase directory so that they can be accessed as http://www.domain1.com and http://www.domain2.com


workers.properties can be as simple as following two lines. Which connects to the worker w1 to ajp port of Tomcat.

worker.list=w1
worker.w1.port=8009


Now to the Apache 2 configuration. Make sure you have uncommented NameVirtualHost *:80 line in httpd.conf. Now add two <VirtualHost> sections for the two domains as below. Note that I have left out other mod_jk configuration directives.

<VirtualHost *:80>
    ServerName www.domain1.com
    JkMount  /* w1
</VirtualHost>

<VirtualHost *:80>
    ServerName www.domain2.com
    JkMount  /* w1
</VirtualHost>


Don' forget to click the +1 button below if this post was helpful.

1 comment:

seoindiarank chennai said...

Very nice post here thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
seo company in chennai