A lot of time we want to run multiple instances of Apache Tomcat server on a single machine. Generally this is done for creating a separate load balancer server for an application or install a different application independently. This can be achieved easy by some configuration in Tomcat Server. We need to install a second instance of Tomcat and change few port in configuration files. Open server.xml from /conf directory of your Tomcat installation folder. Change following ports in server.xml file.
Connector Port
This is the port where Apache Tomcat listen for the HTTP requests. By default this port is set to 8080. We can identify this Port inside server.xml by checking the following tag. Change the port to different value (for example 8081) and the second instance will listen the HTTP request on that port.<connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000" redirectPort="8443" />
Code language: HTML, XML (xml)
Shutdown Port
This port is used when we try to shutdown the Apache Tomcat Server. We can identify this Port inside server.xml by checking the following tag.<server port="8005" shutdown="SHUTDOWN">
</server>
Code language: HTML, XML (xml)
AJP (Apache JServ Protocol) Connector Port
The Apache JServ Protocol (AJP) is a binary protocol that can conduct inbound requests from a web server through to an application server that sits behind the web server. We can identify this Port inside server.xml by checking the following tag.<connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
Code language: HTML, XML (xml)
Redirect Port
Any redirection happening inside Apache Tomcat will happen through this port. In Apache TOMCAT there are two instance where redirectPort is mentioned. First one is for the Apache TOMCAT server and other one is for the AJP port. We can identify this Port inside server.xml by checking the following tag. Ensure that redirectPort should be same for AJP and HTTP protocol.<connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<connector port="8100" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
Code language: HTML, XML (xml)
Just change the above ports in your second installation of Tomcat.
any performance or other issue, if enabling tomcat on multiple ports for the same protocol.?
Hi,
Please help me out.I have Struts2 Application which works fine when I run in localhost…Somehow I am failed to run using Virtual host name…It comes to stating login page after then it cannot execute my action classes….I am try to google for the solution but nothing works out…Please help me on this issue…..
If My application can work in localhost I assume it will works for virtual host also…Please advice me on what can be the possible cause…
Many Thanks and Regards,
Jerson
Thank you very much for your post. It was so simple, even I could understand it.
Thank you for this useful post.
Question: Should anything more be said about the CATALINA_HOME variable and how its setting influences one or the other instance of Tomcat?
CATALINA_HOME should be the main apache-tomcat (simply say, the downloaded one) directory.
CATALINA_BASE should be tomcat-instance_1 directory for instance 1
CATALINA_BASE should be tomcat-instance_2 directory for instance 2 and so on..
Thanks! It works for me =)
Hi
I am trying to run 2 instances of tomcat on my machine. I installed them in two separate folders. And changed the ports in the server.xml for the second tomcat. When I try to start them, the first one to be started gets started. The second one to be started starts and then closes immediately. Is there anything that I am missing?
Thanks
Prachi
Hi Viral:
How to pass these multiple connector through command line as environment variable.
I have used as below.
When i passed, it is giving error at shutdown time. Tomcat is failed to shutdown.
Sriram.