在Linux中运行多个tomcat互不影响,可以独立启动。
- 在/etc/profile中添加配置
#tomcat environment
#0 default
CATALINA_BASE=/usr/local/tomcat/apache-tomcat-7.0.73
CATALINA_HOME=/usr/local/tomcat/apache-tomcat-7.0.73
TOMCAT_HOME=/usr/local/tomcat/apache-tomcat-7.0.73
export CATALINA_BASE CATALINA_HOME TOMCAT_HOME
#1
CATALINA_1_BASE=/usr/local/tomcat_1/apache-tomcat-7.0.73
CATALINA_1_HOME=/usr/local/tomcat_1/apache-tomcat-7.0.73
TOMCAT_1_HOME=/usr/local/tomcat_1/apache-tomcat-7.0.73
export CATALINA_1_BASE CATALINA_1_HOME TOMCAT_1_HOME
#2
CATALINA_2_BASE=/usr/local/tomcat_2/apache-tomcat-7.0.73
CATALINA_2_HOME=/usr/local/tomcat_2/apache-tomcat-7.0.73
TOMCAT_2_HOME=/usr/local/tomcat_2/apache-tomcat-7.0.73
export CATALINA_2_BASE CATALINA_2_HOME TOMCAT_2_HOME
#3
CATALINA_3_BASE=/usr/local/tomcat_3/apache-tomcat-7.0.73
CATALINA_3_HOME=/usr/local/tomcat_3/apache-tomcat-7.0.73
TOMCAT_3_HOME=/usr/local/tomcat_3/apache-tomcat-7.0.73
export CATALINA_3_BASE CATALINA_3_HOME TOMCAT_3_HOME
- 说明
此处在Linux中一共添加了四个tomcat,如果只有一个不需要此配置,添加多个是需要在此说明各tomcat的位置
2.修改相应tomcat的启动文件/usr/local/xxx/tomcat/bin/catalina.sh,在其中添加,最好加载偏前面的位置(其实是给原有的默认变量重新赋值)
#second_tomcat config
export CATALINA_BASE=$CATALINA_3_BASE
export CATALINA_HOME=$CATALINA_3_HOME
3.修改对应/usr/local/xxx/tomcat/conf/service.xml中的启动及关闭端口
...
<Server port="8008" shutdown="SHUTDOWN">
...
<Connector port="8083" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8446" />
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8446" />
-->
...
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8012" protocol="AJP/1.3" redirectPort="8446" />
...