Running two independent tomcats on one machine, instead of one tomcat with multiple instances

Solution 1:

Yes, we do this frequently.

Basically our approach (on Windows) is:

  1. Ensure the full JDK is installed (Tomcat batch files require this)
  2. Download and Tomcat (6.1.20) - the zip version, not the windows installer.
  3. Unzip to a folder named for the purpose of the Tomcat instance (eg to C:\Tomcat6_SW for SuperWEB 1)
  4. Copy the unzipped files to other folders for the other required instances (eg C:\Tomcat6_SW2, C:\Tomcat6_SV)
  5. For each instance, edit server.xml so that there are no port conflicts
  6. For each instance:
    • a. Edit startup.bat to explicitly define CATALINA_HOME and JAVA_HOME
    • b. Rename startup.bat to reflect the purpose of the Tomcat instance, for instance SWstartup.bat for SuperWEB1
    • c. Edit service.bat as above to explicitly define CATALINA_HOME and JAVA_HOME
    • d. Run service.bat to create a Windows service with a service name and description for this Tomcat instance. The service name must be unique, and cannot contain spaces.
    • e. Rename the tomcat6w.exe file to the name of the service that you have created (for instance, if the service name is SWEB1Tomcat, tomcat6w.exe should be renamed to SWEB1Tomcat.exe). If this is not done, the tomcat6w.exe application will not refer to the correct service.
    • f. Run the renamed application and set service properties as follows:
        1. set any Java options required in the Java tab
        1. set the startup type to Automatic
        1. IMPORTANT: change the Log On account to other than “Local System account”, ie something with a lower privilege level.

(Note that you may want to create separate setenv.bat files for each instance.