I saw this question on a forum recently and though the requirement may not be very common, it was certainly an interesting idea. At first I thought it wasn't possible but after little tampering with the registry, it turned out to be quite easy to achieve.
Editing the registry is risky! If you're unsure or can't live with the consequences, don't do it. And remember, ALWAYS BACKUP!
The instructions below are for Tomcat 6.0 which is installed as service on a Windows [XP] machine.
To begin with, these are the keys that are created by the Tomcat installer in the registry; you'll need to modify them. I'll refer to them by their numbers in the steps.
I. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet \Services\Tomcat6
II. HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Procrun 2.0\Tomcat6
III. HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Tomcat\6.0
IV. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows \CurrentVersion\Run
V. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows \CurrentVersion\Uninstall\Apache Tomcat 6.0
VI. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum \Root\LEGACY_TOMCAT6
II. HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Procrun 2.0\Tomcat6
III. HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Tomcat\6.0
IV. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows \CurrentVersion\Run
V. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows \CurrentVersion\Uninstall\Apache Tomcat 6.0
VI. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum \Root\LEGACY_TOMCAT6
- Install your first instance of Tomcat to, say, C:\Tomcat6_1
- Start > Run > regedit > [ENTER] will bring up the registry editor
- Navigate to key I and rename it from [...]Tomcat6 to, say, [...]Tomcat6_1. This will ensure the next install will not overwrite this key
- You should see the values for this key in the right pane; modify DisplayName from Apache Tomcat to, say, Apache Tomcat 1. This is so that you know which service is which later, in the Services console (Start > Run > services.msc > [ENTER])
- Modify the ImagePath value from [...]//RS//Tomcat6 to [...]//RS//Tomcat6_1. This is the name of the service instance that will be started; we'll need this name later so keep it in mind
- The Enum key under key I has a value 0 which points to key VI. Change the data to reflect the change in the key name that you'll be making later i.e. modify Root\LEGACY_TOMCAT6\0000 to Root\LEGACY_TOMCAT6_1\0000
- Navigate to key II and rename it also; from [...]Tomcat6 to [...]Tomcat6_1. Again, this is to avoid overwriting when installing the second service
- Similarly, modify key III from [...]6.0 to [...]6.0_1. Same reason as above
- Navigate to key IV and modify the value (not the value's data) from ApacheTomcatMonitor to ApacheTomcatMonitor_1. This key is for the monitor application; modifying the key will avoid overwriting of the key on the second install and you'll be able to run two instances of the monitor, one for each service
- Now you modify the data of this value; [...]//MS//Tomcat6 to [..]//MS//Tomcat6_1. This is the name of the service that you modified above, for the ImagePath value
- If you want to be able to uninstall both the instances of Tomcat later (recommended!), you need to modify key V and rename it from [...]Apache Tomcat 6.0 to [...]Apache Tomcat 6.0_1. Again, to avoid overwriting of the uninstall information
- I'm not very sure about key VI but I suggest you modify it also. Rename it from [..]LEGACY_TOMCAT6 to [..]LEGACY_TOMCAT6_1
- Restart your system now for the changes to take place
- Once you're sure the current install is working as expected, you can install the second instance of your Tomcat. I installed to C:\Tomcat6_2
- Before you start the second service, you need to change the ports since otherwise it's going to start with exactly the same ones as your first service and throw exceptions and quit. (You could've changed the HTTP listen port while installing) You need to change the HTTP and SHUTDOWN listen ports at least. If either of these is the same or bound to some other process, Tomcat will not start.
- Go to $CATALINA_HOME\conf\server.xml ($CATALINA_HOME refers to the Tomcat install directory)
- Modify the value for <Server port="8005" shutdown="SHUTDOWN"> appropriately
- Ditto for <Connector port="8080" protocol="HTTP/1.1"
- Restart the system and the two instances of the monitor as well as the services should start up with no issues
You can, of course, extend this to any number of services.