Multiple Tomcat Instances

When using Tomcat 5.5 for either development or production it is sometimes useful to have multiple instances of Tomcat running at the same time. The instructions below allow you to set up the minimum tomcat configuration to run multiple Tomcat instances.

  1. Install a Tomcat 5.5 distribution. The CATALINA_HOME environment variable will point to this location.
  2. Create a directory that will be your Catalina base, identified by the environment variable CATALINA_BASE
  3. Within this directory create the following directories
    • logs
    • conf
    • webapps
  4. From your base Tomcat 5.5 distribution copy the following files from $CATALINA_HOME/conf to the conf directory that you have just created:
    • context.xml
    • server.xml
    • tomcat-users.xml
    • web.xml

With this structure one can now run Tomcat. Open a terminal, ensure that the environment variable CATALINA_HOME is set to point at the directory created in (1) above, set the environment variable CATALINA_BASE to point at the directory created in (2) above.

You can now alter the configuration files in $CATALINA_BASE/conf as appropriate. For example edit server.xml to set the port that Tomcat will listen on.

I use this technique for running Tomcat in my development process, the CATALINA_BASE is part of my project structure and I have ANT targets for starting and stopping Tomcat and for deploying the application. As an example consider the following target to start Tomcat:

<target name="tomcat-start" depends="deploy" description="Starts the Tomcat application server">
    <exec executable="${tomcat.home}/bin/">
        <env key="CATALINA_HOME" value="${tomcat.home}" />
        <env key="CATALINA_BASE" value="${dir.deploy}" />
        <arg value="jpda" />
        <arg value="start" />

This site uses cookies. Continue to use the site as normal if you are happy with this, or read more about cookies and how to manage them.