Tuesday, December 11, 2012

Multiple Tomcat Instances Ubuntu

Aim: To have multiple instances on Tomcat which can be started by the command:
sudo service tomcat-<name> start

The easiest method that I found was to install the first instance of Tomcat using:
sudo apt-get install tomcat<version number>

switch to folder /var/lib. A tomcat directory should be formed here e.g. tomcat6 if you installed Tomcat-6. Make a copy of this folder

sudo cp tomcat6 tomcat6-test

open the server.xml file in your new tomcat folder (in our case tomcat6-test).

Change the ports for all connectors in use so that they do not clash with other tomcat instances on your machine. Change the ports in bold:
  • <Server port="8005" shutdown="SHUTDOWN">
  • <Connector port="8080" protocol="HTTP/1.1"  connectionTimeout="20000"                URIEncoding="UTF-8" redirectPort="8443" />
  • <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> (if you are using AJP)
    • Note: do not change the redirectPort values.
go to /etc/init.d folder and make a copy of the tomcat file.

sudo cp tomcat6 - tomcat6-test

open this file for edit and change CATALINA_BASE to point to /var/lib/<new tomcat instance>.

You should now be able to use "sudo service tomcat-<name> start" to start the new tomcat instance.

No comments:

Post a Comment