Install multiple Apache Tomcat instance on Windows

Key steps:
 - Tomcat installation folder
 - Tomcat configuration
 - Tomcat windows service (optional)

1. Install first instance of Apache Tomcat
Just download an Apache Tomcat  Windows Service Installer package from here. Just follow the steps to install. And I would expect the software to be install at this directory "C:\Program Files\Apache Software Foundation\Tomcat 6.0".
if it's already installed, skip step 1.
2. Duplicate Tomcat directory
As mentioned before, your first instance installed in "C:\Program Files\Apache Software Foundation\Tomcat 6.0"; to get the second instance of Tomcat, just copy whole Tomcat directory from "C:\Program Files\Apache Software Foundation\Tomcat 6.0" into "C:\Program Files\Apache Software Foundation\Tomcat 6.0.2". Once you done that, you would have something like this.





3. Configurate the Apache Tomcat instances
By default, Apache Tomcat configured serval ports, for example Connector Port, Shutdown Port, AJP(Apache JServ Protocol) Connection Port & Redirect Port, to run the service. In order to get multiple Tomcat run on a single machine, we need to configurate the following ports on each instance.
Change the following ports in the /conf/server.xml file. Here are the ports we are going to use for the Apache Tomcat instances:
Apache Tomcat 1 (First instance)
Connector Port: 8080 (Default)
Shutdown Port: 8005 (Default)
AJP Port: 8009 (Default)
Redirect Port: 8100 (Default)

Apache Tomcat 2 (2nd instance)
Connector Port: 8081 (or next available port)
Shutdown Port: 8006 (or next available port)
AJP Port: 8010 (or next available port)
Redirect Port: 8101 (or next available port)

Connector Port
This is the port where Apache Tomcat listen to HTTP request.
<connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
Change it according to the Tomcat instance planned on above.
Shutdown Port
This is the port used to shutdown the Apache Tomcat. We have the change the port number by identify the tag as following in server.xml.
<server port="8005" shutdown="SHUTDOWN">
AJP (Apache JServ Protocol) Connector Port
The Apache JServ Protocol (AJP) is a protocol that  conduct inbound requests from a web server 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" />
Redirect Port
Any redirection happening inside Apache Tomcat will happen through this port. In the server.xml, there are two places mentioned the redirectPort. We have the change both places as well.
<connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<connector port="8100" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
Once, you completed the configuration on above, the different instance of  Apache Tomcat should run on different port.
4. Install Windows Services
Open a DOS prompt, and netvigate to Tomcat's bin directory. To install a service, type Tomcat6.exe //IS//<service_name>, where <service_name> is the name of the service you want to create.
Here, we are going to create two extra instance, the steps would be like this:

To create the Windows Service instance for the Tomcat located in C:\Program Files\Apache Software Foundation\Tomcat 6.0.2\bin. Here are the commands.
cd C:\Program Files\Apache Software Foundation\Tomcat 6.0.2\bin

Tomcat6.exe //IS//Tomcat602
or 
Tomcat6.exe install Tomcat602
or
omcat6.exe update Tomcat602 --DisplayName "Apache Tomcat 6.0.2"

Once you completed the above, youe should see there are two extra services in your list of Windows Services.
5. Edit Windows Services
Here we are going to configurate the newly created services. And we are going to execute a command to call the corresponding Windows Service. And the command is like this Tomcat6w.exe //ES//<service_name>.
To edit the Tomcat instance located in C:\Program Files\Apache Software Foundation\Tomcat 6.0.2\bin, we need to make sure that the command prompt located in C:\Program Files\Apache Software Foundation\Tomcat 6.0.2\bin.
cd C:\Program Files\Apache Software Foundation\Tomcat 6.0.2\bin

Tomcat6w.exe //ES//Tomcat602

And you will see a window popup with 6 tabs, now you need to follow the following pictures to do the settings. then fill in settings for this new instance like first instance
Tomcat Windows Service configuration - Tab One
Tomcat Windows Service configuration - Tab Two
Tomcat Windows Service configuration - Tab Three
Tomcat Windows Service configuration - Tab Four
Tomcat Windows Service configuration - Tab Five
Tomcat Windows Service configuration - Tab Six















No comments :

Post a Comment