Tuesday, May 5, 2009

Running 2 tomcats on a single machine

Very simple thing but very important and needed many a times. The simple to follow steps.
1) Download tomcat and unpack it in 2 different directories. Lets say /sfw/tomcat1 and /sfw/tomcat2 or if it is windows c:\sfw\tomcat1 and c:\sfw\tomcat2.
2) Edit the conf/server.xml file in both the tomcat installations and make sure the ports are different. For example if tomcat1 has the following config snippet -

<Server port="8005" shutdown="SHUTDOWN">
.....................
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
....................
<Connector port="8009" protocol="AJP/1.3" redirectport="8443">

Then tomcat2 should have something like
<Server port="8006" shutdown="SHUTDOWN">
....................
<Connector port="8081" protocol="HTTP/1.1" connectiontimeout="20000" redirectport="8444">
....................
<Connector port="8010" protocol="AJP/1.3" redirectport="8444">


Thats it for the basic config.