linux环境下配置和使用多个tomcat

(1)修改/etc/profile文件。添加一组java环境变量,和两组CATALINA环境变量(我没有进行此步骤的设置,可能因为我的Tomcat是免安装版的吧)
 
记得修改完要使其生效,用命令:source /etc/profile

JAVA_HOME=/usr/java/jdk1.7.0
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME
export PATH
export CLASSPATH
#第一个Tomcat
export CATALINA_BASE=/usr/local/apache-tomcat-6.0.35
export CATALINA_HOME=/usr/local/apache-tomcat-6.0.35

#第二个Tomcat
export CATALINA_2_BASE=/usr/local/apache-tomcat-6.0.35-second
export CATALINA_2_HOME=/usr/local/apache-tomcat-6.0.35-second
(2).修改server.xml配置和第一个不同的启动、关闭监听端口。修改后示例如下:
<Server port="8050" shutdown="SHUTDOWN">  端口:8049->8050
<!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
    <Connector port="9080" maxHttpHeaderSize="8192" 端口:8080->9080
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               connectionTimeout="20000" disableUploadTimeout="true" />
 
(3)打开catalina.sh ,tomcat/bin/找到下面红字,在下面增加如下代码
# OS specific support.  $var _must_ be set to either true or false.
# myself : add
export CATALINA_BASE=$CATALINA_2_BASE
export CATALINA_HOME=$CATALINA_2_HOME

相关推荐