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