Creating a Multi-Instance Railo Install with Tomcat

If you want to run multiple instance of Railo on a single server then keep reading because I am going to show you how to do just that using a single physical Tomcat and Railo install.

Requirements

You will need to have the latest Java JDK installed, then grab Tomat 6 zip, and Railo 3.1.2 Jars.

Once you have downloaded the required files we can begin.

Unpacking

Unpack the Tomcat 6 zip file to your Hard-drive, I unpacked min to d:\tomcat6. Next unpack the Railo 3.1.2 jar files to d:\tomcat6\railojars. Double check to make sure that the jar files are directly in the railojars directory, once you have done that we are ready to begin with the configuration.

Configuring Tomcat

Catalina.properties

Now that we have our Railo jar files external to the Tomat lib directory we need to update the Catalina.properties file located in conf directory. On approximately line 47 of the Catalina.properties file you should see the following:


common.loader=${catalina.home}/lib,${catalina.home}/lib/*.jar

Edit this line so that it looks like this:


common.loader=${catalina.home}/lib,${catalina.home}/lib/*.jar,${catalina.home}/railojars/*.jar

This is a list of directories telling tomcat where to look for jar files, if we didn't modify this line Tomcat wouldn't know where we put the Railo jar files.

Setting up our Instances

The first then we are going to do is create the directory server under d:\tomcat6, in this directory create a directory to hold your first instance e.g. instance1. We then create the following directories [conf,logs,temp,webapps,work] under instance1 and then copy Catalina.properties, server.xml, and web.xml from the d:\tomat6\conf directory into d:\tomcat6\server\instance1\conf.

Once we have done that we can then start working on configuring our Instance

Configuring the Instance

Web.xml

Set up the railo servlet, mappings and add the index.cfm to the welcome-list area. Check out my post on Installing Railo 3 on SUSE 10 With Apache2 and Tomcat for the xml snippets you need for the web.xml file.

We will be adding one more init-param to the servlet mapping to make sure that when we start configuring our instances they will have their own server context. Make sure your init params look like the following:


    <init-param>
         <param-name>railo-server-directory</param-name>
         <param-value>d:/tomcat6/server/instance1/railo-server-config/</param-value>
         <description>Configuraton directory</description>
     </init-param>
    <init-param>
     <init-param>
             <param-name>configuration</param-name>
             <param-value>d:/tomcat6/server/instance1/railo-web-config/{web-context-hash}</param-value>
             <description>Railo Web Directory</description>
         </init-param>
     <load-on-startup>2</load-on-startup>

That is all we need to change in the Web.xml

Server.xml

In order to run multiple instances of Tomcat on the same machine we need to make sure that the ports that tomcat listen to are unique for each instance. So we need to decide on a numbering scheme for the ports to ensure that they are unique, for example the instance number.

We first need to change the server port that Tomcat listens to from the default 8005, here we can use our instance number and change the port to 8115, change the http port from 8080 to 8110 (or comment it out if you plan on hooking tomcat up to Apache), and the Ajp port from 8009 to 8119.

Railo Host entry Set up your railo host entry to point it to where you are going to have your cfm files.


<Host name="project1.local" appBase="D:/tomcat6/server/instance1/webapps">
    <Context path="" docBase="D:/projects/project1"/>
</Host>
Save and close the server.xml file.

Starting the Instance

We have created our instance but how do we start it up and from where? We need to create a customized startup.bat file for our instance. You will need to have a JAVA_HOME, and a CATALINA_HOME environment variable, if you don't then go ahead and create that now. As a reminder CATALINA_HOME should point to the main tomcat directory and JAVA_HOME to the main directory where you installed Java. Create a new file called startup_instance1.bat and add the following:


set CATALINA_BASE=d:\tomcat6\server\instance1
set CATALINA_HOME=%CATALINA_HOME%
%CATALINA_HOME%\bin\catalina start %1 %2 %3 %4 %5 %6 %7 %8 %9

Save the file and either double-click or call the file from the command prompt, your shiny new instance should spring to life and be available at http://project1.local:8110

To create another instance follow the following steps:

  1. Copy instance 1, rename it to your new instance
  2. Delete the railo-server-config, and railo-web-config directories
  3. Clear out the logs and work directories
  4. Modify the web.xml and server.xml as indicated above
  5. Copy the startup_instance1.bat and rename it to your new instance
  6. Change the CATALINA_BASE to point to your instance, save the file and start it up.

There you have it, multiple Tomcat server instances running Railo using a single Install of Tomcat and Railo, each Railo instance will have it's own Railo Server and Web Contexts.

Happy Coding...

Related Blog Entries

0 Comments to "Creating a Multi-Instance Railo Install with Tomcat"- Add Yours

Powered By Railo

Subscribe

Subscribe via RSS
Follow garyrgilbert on Twitter Follow me on Twitter
Or, Receive daily updates via email.

Tags

adobe air ajax apple cf community cfml coldfusion examples ext flash flex google javascript max2007 max2008 misc open source programming railo software technology ui

Recent Entries

No recent entries.

Blogroll

An Architect's View
CFSilence
Rey Bango
TalkingTree

Wish List

My Amazon.com Wish List