Tomcat multiple instances on Linux, Ubuntu / Mint

I was trying to figure out how to run multiple instances of Tomcat6 the other day on my Mint Linux. After a bit of searching and poking around I came to a very slick solution. But it took a while to find it, so I figure I will share the quick and dirty here, to get you up going quickly if your searching for the same.

Lets go through the whole thing, install Tomcat6
>sudo apt-get install tomcat6

You might have to set your java path if not set already, for example
>export JAVA_HOME=/usr/java/jdk1.6.0/bin/java
To check the setting
>echo $JAVA_HOME

You probably want to install the examples as well, just to mae sure things are working servlets, jsp etc,
>sudo apt-get install tomcat6-examples

If all is well as you would fully expect, you can start your Tomcat
>sudo sh /etc/init.d/tomcat6 start

And in return you will be able to access your tomcat in your browser at
http://localhost:8080

So lets take a look at how to configure multiple instances on the same linux box. Go to a directory where you want your new tomcat instance located. Then you do something like this
>tomcat6-instance-create myInstance

This will create a new directory called myInstance which will host your new instance of Tomcat. It will have it’s own configuration files, logs, etc. The first thing you probably want to do is to go to the config directory and change the ports in the server.xml file. Once you have the ports changed from the usual 8080 you can start your instance from /myInstance/bin directory.
>sh startup.sh

Just as you would with any other instance of Tomcat and shut down with the shutdown.sh script. Next time you need another instance on another port just create a new one
>tomcat6-instance-create myInstance_8030
and so on and so forth.

All the details can be found in the Ubuntu documentation.

One Comment

  1. I have written a Java based portable utility for automating the above steps for creating multiple instances. Since Java is platform independent, this utility works on all operating systems

Leave a Reply