Using Multiple Instances of Tomcat On CentOS










Step 1 :
Download Tomcat 7.0.82 using following command
#wget http://www-us.apache.org/dist/tomcat/tomcat-7/v7.0.82/bin/apache-tomcat-7.0.82.tar.gz





Step 2: 
Once download is completed, extract tar file in /opt/tomcat1


Step 3:
Download Tomcat 8.0.47 using following command

#wget http://www-us.apache.org/dist/tomcat/tomcat-8/v8.0.47/bin/apache-tomcat-8.0.47.tar.gz  




Step 4: 
Once download is completed, extract tar file in /opt/tomcat2


Step 4.1 : Edit catalina.sh Script

Now let's edit the catalina.sh script so that it would know the about catalina_home and catalina_base

#cd /opt/tomcat1/apache-tomcat-7.0.82/bin
#nano catalina.sh  



Step 4.2 : Edit Tomcat Configuration File. 

Just replace the port numbers of server.xml from following script.
Basic elements of server.xml file
Listeners :
There are few Listeners in the Server. Main task of a Listener is to listen and response to particular events.
Connectors :
All the communications occurring with client are handled by Connector.
Connectors available in Tomcat :
HTTP connector : handles most of the HTTP traffic
AJP connector : implements the AJP protocol used when connecting Tomcat to another web server .
Tomcat has a connector to handle HTTP communication. And by default this port keeps waiting for requests to come through port 8080. That's the reason the URLs of every examples always start with http://localhost:8080/.
The connectionTimeout is set to 20,000. It states that a session will terminate after 5 hours, 33 minutes, and 20 seconds of inactivity. The redirectPort=”8444″ states that the incoming requests will be redirected to port 8444 but only the requests which require Secure Socket Layer (SSL) transport.
Containers :
In tomcat Engine, Context, Cluster and Host are containers. Here on top level is Engine and at the lowest-level is Context. Other components, like Valve and Realm, can be placed inside a container.
Engine:
This is the top level container. It might have more than one hosts. If we want to run Tomcat server on different hostnames, we have to configure a Tomcat server, which is also called as virtual host.

Catalina Engine : It accepts HTTP requests from the HTTP connector, and redirect them to the correct host based on the hostname/IP address which is in the request header.

Step 5 : Start Tomcat 7
First change the directory to bin folder



Step 6 : Start Tomcat 8
First change the directory to bin folder


So, we can see that both the instances of tomcat are running on different ports at the same time. 
So when we have to run more than instances of Tomcat for different purposes it can be done by using these steps .

**************************************************************************************************
if you find any mistake please let me know through comment or through  contact form
Thank u ðŸ˜Š



Newest