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.

JDBC Driver Class Names and URL Formats For Popular Databases

A recurring pain for me is digging up JDBC driver class names and URL formats when ever I need to connect to a database over JDBC. So I thought I will document driver / URL details plus additional info such as Spring DBCP configuration, Tomcat datasource configuration and connection validation SQL information for all popular databases.

I have published this info on the internet and you can view them at http://www.kengsi.com/jdbcwiz.html. Hope this will help few others by having this information in one single place. I will add more databases as time goes on so if you don't see information about a database driver you are interested in, please do let me know.


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