Installing Apache Tomcat 5.5/6/7 with a multi-instance layout on Linux

Purpose
Apache Tomcat is designed to provide a single instance of a server. However, it is easy to configure multiple instances based on a single installation, which provides the following benefits: 
  • Ability to quickly deploy multiple instances from one shared Tomcat distribution version.
  • Ability to upgrade all Tomcat instances by just upgrading a single installed Tomcat distribution version.
  • Instance configuration separate from the installation, and without multiple copies of the same Tomcat version on a single platform, offering greater flexibility and  manageability.
This article provides information on instance configuration with Tomcat 6.0.35. Other versions can be used similarly.
Resolution

Downloading and installing Tomcat

  1. Download the ASF Tomcat tarball binary distribution.
  2. Extract the archive files to your installation path. You may use any path you prefer. However, in this instance we have chosen /opt/tomcat6

    > cd /opt

    > tar xvzf apache-tomcat-6.0.35.tar.gz
    > mv apache-tomcat-6.0.35 tomcat6

    This regular Tomcat installation serves as the reference (CATALINA_HOME) for our multiple instances.

  3. Install a supported Java JDK or JRE in order to run Tomcat.

    Note: See the RUNNING.txt file from your Tomcat download for details.

 

Configuring an instance of Tomcat

An instance of Tomcat has its own directory, referred to as CATALINA_BASE, separate from the Tomcat install in CATALINA_HOME.

  1.  Define your chosen CATALINA_HOME and CATALINA_BASE paths as shell variables:

    > CATALINA_HOME=/opt/tomcat6

    > CATALINA_BASE=/opt/tc6-instances/example1

  2. Create your Tomcat instance base path:

    > mkdir -p $CATALINA_BASE


  3. Copy some default Tomcat content to the instance base path:

    > cp -r $CATALINA_HOME/conf $CATALINA_BASE

    > mkdir $CATALINA_BASE/bin
    > cp $CATALINA_HOME/bin/*.sh $CATALINA_BASE/bin

  4. Create empty folders for the instance to use:

    > mkdir $CATALINA_BASE/{webapps,logs,temp,work,lib}

  5. Copy setenv.sh (attached at the bottom of this article; or create your own) to $CATALINA_BASE/bin. This script is sourced by the Tomcat scripts and can be used to specify instance-specific environment variable settings. If you do not define these environment variables in setenv.sh, the shell environment variables or script defaults are used instead.
  6. Modify variables in setenv.sh to match your Tomcat deployment instance environment:

    CATALINA_HOME=/opt/tomcat6
                
    CATALINA_BASE=/opt/tc6-instances/example1
    CATALINA_PID=$CATALINA_BASE/temp/tomcat.pid
    JAVA_HOME=/path/to/your/JDK
      or JRE_HOME=/path/to/your/JRE     (If not set, the startup script may find one in your environment)

    Note: Set any other custom JVM options in setenv.sh if necessary.

  7. Edit your $CATALINA_BASE/conf/server.xml to specify connector ports and shutdown port that do not conflict with ports already in use by other server instances.
Your instance is now ready to use. You can start and stop your Tomcat instance with the instance $CATALINA_BASE/bin/{catalina.sh,startup.sh,shutdown.sh} scripts as usual. 

You can repeat these steps with a different CATALINA_BASE each time to create as many Tomcat instances as your platform can handle. You must customize at least the conf/setenv.sh and conf/server.xml files for each instance.
Additional Information
See Also
  • Deploying ASF Tomcat 6.0 using multi instances layout on Windows OS
  • Running Apache Tomcat instance as a daemon on Linux
Attachments
  • setenv.sh

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值