Sunday, July 30, 2006

Advanced Configuration - Multiple Tomcat 5.5 Instances on Linux

Create account tomuser as in [1] with .bash_profile following bellow.

Export new environment variable CATALINA_BASE pointing for example to ~tomuser.

# su - tomuser
$cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc

# User specific environment and startup programs
export CATALINA_BASE=~tomuser
export CATALINA_HOME=/home/tomcat/apache-tomcat-5.5.16
export JAVA_HOME=/home/tomcat/jdk1.5.0_06
export ANT_HOME=/home/tomcat/apache-ant-1.6.5
export PATH
export CLASSPATH=.:..:../..:$CATALINA_HOME/common/lib/servlet-api.jar:$CATALINA_HOME/common/lib/jsp-api.jar:
export DISPLAY=:0.0


$cp -R $CATALINA_HOME/conf .
$cp -R $CATALINA_HOME/webapps .
$cp -R $CATALINA_HOME/shared .
$cp -R $CATALINA_HOME/work .
$cp -R $CATALINA_HOME/temp .
$cp -R $CATALINA_HOME/logs .
$cd /home/tomuser/conf/Catalina/localhost

Modify 3 files admin.xml,host-manager.xml,manager.xml.

Context should contain new value for docBase.

In particular manager.xml should look like:-

<Context docBase="/home/tomuser/server/webapps/manager"
privileged="true" antiResourceLocking="false" antiJARLocking="false">

<!-- Link to the user database we will get roles from -->
<ResourceLink name="users" global="UserDatabase"


$cp -R $CATALINA_HOME/server .
$cd conf

Modify server.xml. Three ports values should be changed:-

<Server port="8015" shutdown="SHUTDOWN">


<!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
<Connector port="8090" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />


<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8019"
enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />

To start new TomCat instance:-

$ $CATALINA_HOME/bin/ -Dcatalina.base=$CATALINA_BASE

Screenshot of $CATALINA_BASE/logs/catalina.out:-

Screenshot of "admin" report:-

To perform deployment with "ant" to new instance of TomCat :-

$ cd apache-tomcat-5.5.16-deployer

Make one change to build.xml,replacing old port value for TomCat by new one.

<!-- Configure properties to access the Manager application -->
<property name="url" value="http://localhost:8090/manager"/>
<property name="username" value="tomcat"/>
<property name="password" value="tomcat"/>\>