How to Run Multiple Instances of Apache Tomcat on One Server (Windows)

See Apache: Tips and Tricks for similar articles.

In another topic, I discussed how to start one member of a Tomcat cluster. Click here to learn how to cluster in Apache Tomcat (Windows). When you have completed the work in that topic, you will be prepared for this topic. I will show you how to run another Tomcat instance on the same server, or computer.

To learn how to run multiple instances of Apache Tomcat on one server, follow these 15 steps:

  1. Having competed the topic mentioned above, you currently have "TomcatA" running. You will now proceed by creating "TomcatB".
  2. Create a directory under the C: drive named TomcatB.
  3. Copy CATALINA_BASE/conf to your new directory.
  4. Open an edit session on c:/TomcatB/conf.server.xml. Locate the cluster entry:
    <!--
    <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
    -->
    	
    Note that the entry is commented out.
  5. Remove the comment tags:
    <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
           
    	
    Note that the entry is commented out.
  6. Now locate the Connector element for HTTP:
    <Connector port="8080" protocol="HTTP/1.1"	
    	connectionTimeout="20000"
    	redirectPort="8443" />
    	
  7. Change the port number to "8282":
    <Connector port="8181" protocol="HTTP/1.1"
    	connectionTimeout="20000"
    	redirectPort="8443" />
    	
    We want to change the HTTP port so that there will be no contention for the port when we start our customized Tomcat.
  8. Locate the Server element:
    <Server port="8005" shutdown="SHUTDOWN">
    	
  9. Change the port number to "8002":
    <Server port="8002" shutdown="SHUTDOWN">
    	
    We also want to change the shutdown port so that there will be no contention for the port.
  10. Save your changes.
  11. Start a command prompt and navigate to CATALINA_HOME/bin.
  12. Set the environment variable CATALINA_BASE to c:/TomcatB:
    set CATALINA_BASE=c:/TomcatB
    	
    Now when we start the server, Tomcat will pick up our new configuration, including the updated server.xml.
  13. Start Tomcat: Start TomcatNote that CATALINA_HOME and CATALINA_BASE have different values. CATALINA_HOME is the original installation directory that contains our web applications whereas CATALINA_BASE contains our customized configuration.
  14. In your browser, enter the URL that includes the new HTTP port number, http://localhost:8282: Tomcat Welcome PageThe welcome page will display, indicating the new configuration that includes clustering has been installed by Tomcat.
  15. From the earlier topic referenced above, you have a running instance of "TomcatA". Now you have two instances of Tomcat running on your computer.

Related Articles

  1. How to Start and Stop Apache Tomcat from the Command Line (Windows)
  2. How to Deploy a WAR File to Apache Tomcat (Windows)
  3. How to Start and Stop Apache Tomcat from the Command Line (Linux)
  4. How to Deploy a WAR File to Apache Tomcat (Linux)
  5. How to Run a JSP Program in Apache Tomcat (Windows)
  6. How to Check the Status of the Apache Tomcat Server (Windows)
  7. How to Deploy a Web Application Using the Apache Tomcat Manager (Windows)
  8. How to Check the Status of the Apache Tomcat Server (Linux)
  9. How to Set Default Context Path in Apache Tomcat (Windows)
  10. How to Use the autoDeploy Attribute in Apache Tomcat (Windows)
  11. How to Deploy a Web Application Using the Apache Tomcat Manager (Linux)
  12. How to List Deployed Applications Using the Apache Tomcat Manager (Windows)
  13. How to Run Multiple Instances of Apache Tomcat on One Server (Windows) (this article)
  14. How to Run a JSP Program in Apache Tomcat (Linux)
  15. How to Establish a JDBC Connection in Apache Tomcat (Windows)
  16. How to Verify Apache Tomcat Server Operation (Windows)
  17. How to Cluster in Apache Tomcat (Linux)
  18. How to Undeploy Web Applications Using the Apache Tomcat Manager (Windows)
  19. How to Set Default Context Path in Apache Tomcat (Linux)
  20. How to Use the Java Logging API in Apache Tomcat (Windows)
  21. How to Cluster in Apache Tomcat (Windows)
  22. How to Use the Java Logging API in Apache Tomcat (Linux)
  23. How to Use the autoDeploy Attribute in Apache Tomcat (Linux)
  24. How to Configure Apache Tomcat to Use MBeans (Windows)
  25. How to List Deployed Applications Using the Apache Tomcat Manager (Linux)
  26. How to Install and Configure Apache Tomcat (Windows)
  27. How to Configure Apache Tomcat to Use MBeans (Linux)