一台服务器上部署多个tomcat

参考:https://tsov.net/home/view/2141/

  只部署一个tomcat, 不用配置环境变量。但部署多个,每个tomcat的配置文件里 $CATALINA_BASE 和 $CATALINA_HOME 指向的都是同一个默认的环境变量, 所以需要在/etc/profile里为每个tomcat配置环境变量

#tomcat
export CATALINA_BASE=/usr/local/tomcat/apache-tomcat-8.0.48 export CATALINA_HOME=//usr/local/tomcat/apache-tomcat-8.0.48 export TOMCAT_HOME=/usr/local/tomcat/apache-tomcat-8.0.48 #tomcat1 export CATALINA_1_BASE=/usr/local/tomcat1/apache-tomcat-8.0.48 export CATALINA_1_HOME=//usr/local/tomcat1/apache-tomcat-8.0.48 export TOMCAT_1_HOME=/usr/local/tomcat1/apache-tomcat-8.0.48 #tomcat2 export CATALINA_2_BASE=/usr/local/tomcat2/apache-tomcat-8.0.48 export CATALINA_2_HOME=//usr/local/tomcat2/apache-tomcat-8.0.48 export TOMCAT_2_HOME=/usr/local/tomcat2/apache-tomcat-8.0.48

保存,执行source /etc/profile 使配置文件生效。

将环境变量写入对应的tomcat的catalna.sh中,默认的tomcat不用写入,同理端口也是不用修改

# OS specific support.  $var _must_ be set to either true or false.
export CATALINA_BASE=$CATALINA_1_BASE
export CATALINA_HOME=$CATALINA_1_HOME
# OS specific support.  $var _must_ be set to either true or false.
export CATALINA_BASE=$CATALINA_2_BASE
export CATALINA_HOME=$CATALINA_2_HOME

修改每个tomcat端口启动即可。

posted @ 2021-06-23 15:14  wujingqi  阅读(103)  评论(0编辑  收藏  举报