The RUNNING.txt that comes with tomcat distribution indicates the use of CATALINA_BASE variable to enable multiple tomcat instance. But how can I set the CATALINA_BASE environment variable for each tomcat instance directory?
3 Answers
Having multiple Tomcat instances on your development machine is great. Here's how I usually do it for Windows (the important parts for setup are in steps 2, 3, 4 and 5):
- Install a copy of Tomcat 6 to a directory (like C:\apache-tomcat-6.0.20).
- Copy the conf directory to another directory (like C:\tomcat-1)
- Under C:\tomcat-1, create a bin directory
In the C:\tomcat-1\bin directory, create a file called startup.bat that reads like this:
set CATALINA_BASE=C:\tomcat-1
set CATALINA_HOME=C:\apache-tomcat-6.0.20
C:\apache-tomcat-6.0.20\bin\startup.bat
In the C:\tomcat-1\bin directory, create a file called shutdown.bat that reads like this:
set CATALINA_BASE=C:\tomcat-1
set CATALINA_HOME=C:\apache-tomcat-6.0.20
C:\apache-tomcat-6.0.20\bin\shutdown.bat
OPTIONAL: create a file called setenv.bat in the C:\tomcat-1\bin directory to set any environment variables mentioned in C:\apache-tomcat-6.0.20\bin\catalina.bat. This is the place to set system properties, JPDA addresses, etc.
- Create the logs, temp, webapps and work directories under C:\tomcat-1
- From the C:\tomcat-1 directory, run bin\startup.bat
- Repeat for your other installs from step 2 for as many tomcat instances as you need.
Try not to install Tomcat in a directory that has spaces in its name. It should work, but you'll experience fewer problems that way. I do not know how this would work if you were using the "tomcat as a service" option for Windows.
From here, you should be able to isolate tomcat instances. Just be sure to edit your conf\server.xml file so that the shutdown ports and HTTP connector ports don't interfere with other Tomcat instances that may be running. I usually assign values like 8005, 8006, 8007, etc. for the shutdown port and 8080, 8081, 8082, etc. for the HTTP connector port.

- 2,135
- 18
- 22
-
1Excellent answer, but could you please fix the typos and things like: conf directory is needed, shutdown.bat in step 5 instead of startup.bat and CATALINA_HOME has to be set and point to the actual tomcat installation – kosoant Jan 03 '11 at 11:43
-
This has been done. Thank you for pointing these out. This is a better answer than it was before. – Andy Gherna Jan 05 '11 at 15:08
-
Wait though. Step 2 states "Copy the conf directory to another directory (like C:\tomcat-1)" Creating conf in step 7 is unnecessary. Perhaps a better wording to this answer would be in the short answer section specify steps 2, 3, 4 and 5. This has been changed. – Andy Gherna Jan 05 '11 at 22:45
-
1Excellent answer :-), I managed to create a beast :-) Thanks a lot – Jeril Kuruvila Jul 15 '14 at 12:15
-
Thanks a lot 'Andy Gherna' Excellent and simple answer helped me alot, and may I know how to alot a separate jvm to tomcat if possible. AnyWay Thanks a lot again – RamBen Jul 23 '14 at 04:21
-
Hi Andy, can we maintain individual catalina properties for individual webapp on one single instance of tomcat, means I have created multiple webapps under one tomcat and copied my same code base to those webapps. now I want to give individual catalina properties to them. could we do this? or we need to do the way you suggested. – yatinbc May 29 '17 at 07:05
-
@yatinbc, I think so yes. As long as you followed step 2 above, you will be able to configure catalina.properties for each individual Tomcat instance to be whatever you want them to be. – Andy Gherna May 30 '17 at 19:22
There is an easier way. Simply don't define the CATALINA_HOME as a Environment variable on your machine. startup.bat and shutdown.bat already come with the following code:
if not "%CATALINA_HOME%" == "" goto gotHome
set "CATALINA_HOME=%CURRENT_DIR%"
You should be all set. PS: Remember to edit server.xml and put a new port number though. :)

- 51
- 1
- 1
-
-
In general, it works, but that `%CURRENT_DIR%` is actually `%cd%`. So, if you run the script from another directory (using its absolute path), the `%CATALINA_HOME%` will have a wrong value. – ROMANIA_engineer Jan 14 '16 at 09:17
This link has an answer that worked well for me. One thing some of the other answers seems to ignore is that there are multiple places in the server.xml file that must be modified. Before stumbling on this answer mu tomcat servers were competing with each other for certain ports. I had changed the HTTP/1.1 connector port to 8081, but neglected to change some other ports that apparently mattered for my tomcat (version 7). FWIW I had one tomcat service version and one non-service version.
First server.xml file
<connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
<server port="8005" shutdown="SHUTDOWN"/>
<connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<connector port="8100" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
Second server.xml file
<connector port="8081" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
<server port="8006" shutdown="SHUTDOWN"/>
<connector port="8010" protocol="AJP/1.3" redirectPort="8443" />
<connector port="8101" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
http://www.ansoncheunghk.info/article/5-steps-install-multiple-apache-tomcat-instance-windows

- 7,155
- 8
- 41
- 40