Installing Multiple instances of Apache Tomcat

INTRODUCTION


Apache Tomcat is an open source web server and servelet container developed by Apache Software Foundation. This is cross platform application i.e. works on Windows, Linux and MacOS.
There are many big website which are running on Apache Tomcat webserver such as Wordpress.

Components of Tomcat

1)  Catalina (a servlet container)
2)  Coyote (an HTTP connector)
3)  Jasper (a JSP Engine)

Tomcat Directory Structure


1) /bin : Startup, shutdown, and other scripts. 
2) /conf : Main configuration file of Tomcat
3) /webapps : All webapplications are deployed in this Directory.
4) /lib : Java Archive files on which tomcat is dependent upon.
5) /log : Tomcat log files.
6) /work : Here Tomcat place all servlets which  are generated from Jsp's 


Installing Java


Before installing Tomcat we have to be sure that Java is install on the system.

~]# yum install java -y
~]# java -version

Installing Tomcat

 
Download Tomcat from bellow URL:

 http://mirror.fibergrid.in/apache/tomcat/tomcat-8/v8.5.5/bin/apache-tomcat-8.5.5.tar.gz

Copy instances in the directory where you want to do Tomcat installation.

Here, I am installing Tomcat in /etc/ directory.

~]# mkdir -p /etc/tomcat1 /etc/tomcat2                                                                                    ~]# cp -ar apache-tomcat-8.5.5/* /etc/tomcat1                                                                                              ~]# cp -ar apache-tomcat-8.5.5/* /etc/tomcat2
We will create two instances of Tomcat in /etc/tomcat1 and /etc/tomcat2 directory.

Change Http, Https, AJP, Shutdown ports for tomcat2 instance in /etc/tomcat2/conf/server.xml file.

<Server port="8006" shutdown="SHUTDOWN">                                                                                      <Connector port="8081" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8444" />                                                                                             <Connector port="8010" protocol="AJP/1.3" redirectPort="8444" />
 Go
Now Go to /etc/tomcat1/bin directory and rename startup.sh to tomcat1.sh.

Similarly, for second instance Go to /etc/tomcat2/bin directory and rename startup.sh to tomcat2.sh.

Make sure that both files has executable permission.

Now start both instances one by one as follow.

~]# cd /etc/tomcat1/bin/                                                                                                                ~]# ./tomcat1.sh

~]# cd /etc/tomcat2/bin/                                                                                                                           ~]# ./tomcat2.sh
Verify both instances of tomcat by going into browser.

~]# lynx localhost:8080                                                                                                        ~]# lynx localhost:8081

Now you are running with multiple instances of Apache tomcat on same server.







Comments