How to run multiple instances of Tomcat in one Windows machine
January 18th, 2010 by Sanjay Regmi
Sometimes, you might want to run two web applications using Tomcat on one server and want each installation to be separate. This provides isolation of the application and you can change configuration of each one of them separately. Here is a stepwise instruction for the same using Tomcat 6 on Windows 2003 server.
Assumption:
You have a working copy of Java JRE installed on your machine. If not, any JRE above version 5.0 and later is fine. Install it from here, if you need it.
The process:
1. Download Tomcat
Download Tomcat (the core, zipped version) from here and upzip in two different folders, for example c:\tc1 and c:\tc2.
2. Setup environment variable
Go to Start, Control Panel, System, Advanced, Environment Variables, System Variables. Click New. In variable name, input “CATALINA_HOME” and “c:\tc1″ in variable value, without quotes. Then press OK. Again, in System Variables, click New. In Variable name, input “CATALINA_HOME2″ and “c:\tc2″ in variable value, without quotes. Press OK thrice.
3. Setup new CATALINA_HOME variable
Go to c:\tc2\bin directory. Open startup.bat in notepad. Click on the edit menu and then replace. Find all instances of CATALINA_HOME and replace with CATALINA_HOME2. Do the same for catalina.bat and shutdown.bat in c:\tc2\bin.
4. Provide new ports.
Now go to c:\tc2\conf directory and open server.xml in notepad. There are three replacements to be done here.
-
- Find code fragment, “Server port=”8005″ shutdown=”SHUTDOWN”". Replace 8005 with 8105.
-
- Find code fragment, “Connector port=”8080″ protocol=”HTTP/1.1″”. Replace 8080 with 8100.
- Find code fragment, “Connector port=”8009″ protocol=”AJP/1.3″ redirectPort=”8443″”. Replace 8009 with 8109.
Note: you can replace with any port number as long as you know it is free.
5. Check installation
You are done setting both the tomcats up. Goto c:\tc1\bin and double-click on startup.bat. Tomcat instance should be up and running. Open up a browser and input http://localhost:8080. You should see the familiar tomcat start page. Then goto c:\tc2\bin\ and double-click on startup.bat. Tomcat instance two should be up and running. Point your browser to http://localhost:8100 and you should again see the tomcat startup page.
You can create as many new instances of tomcat as required by repeating the above steps. Just make sure that all ports that you use (step 4) are free.
Troubleshooting:
-
- Make sure you downloaded the zipped version.
-
- Make sure step 2, which defines tomcat home is done properly.
-
- Check step 3 – the replacement of CATALINA_HOME to CATALINA_HOME2 should be thorough.
- The new ports in step 4 (8105, 8100, 8109 ) should all be free.
Let me know if you have a better or a quicker setup method.
![](http://www.revasolutions.com/img/twitter.gif)
Tags: Apache Tomcat, Documentum, Tomcat
5 Responses to “How to run multiple instances of Tomcat in one Windows machine”
Thank you for this article. After being at this for more than 2 hours I easily made this work. My only change was that I was using BEA JROCKIT so had to change my JAVA_HOME to it. Also one of my webapps needed the line :-Dsun.lang.ClassLoader.allowArraySyntax=true
so I had to add that into the catalina.bat (last lines).
Thanks again!
Opps, parser thought I wanted a smiley. Here is correct line:
– Dsun.lang.ClassLoader.allowArraySyntax=true
Thanks for your input…
Thanks :)
Very short and Simple steps …
Thanks a lot. Keep up the good work.