一台服务器部署两个项目两个tomcat

时间:2021-01-31 07:32:59

一、复制tomcat到目录

cp -r /usr/local/tomcat7 /usr/local/tomcat7_2

二、修改profile文件

vi /etc/profile

export JAVA_HOME=/usr/local/jdk6
export JRE_HOME=/usr/local/jdk6/jre
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar


export TOMCAT_HOME=/usr/local/tomcat7
export CATALINA_HOME=/usr/local/tomcat7
export CATALINA_BASE=/usr/local/tomcat7


export TOMCAT_HOME2=/usr/local/tomcat7_2
export CATALINA_HOME2=/usr/local/tomcat7_2
export CATALINA_BASE2=/usr/local/tomcat7_2

重启profile文件  source /etc/profile

三、修改配置文件catalina.sh

文件在/usr/local/tomcat7/bin目录下

vi /usr/local/tomcat7_2/bin/catalina.sh

:%s/CATALINA_HOME/CATALINA_HOME_2/g    替换所有

 在# OS specific support.  $var _must_ be set to either true or false.下添加

export CATALINA_BASE=$CATALINA_BASE2
export CATALINA_HOME=$CATALINA_HOME2

四、修改端口

修改conf里面的server.xml

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

 <Connector port="8080" protocol="HTTP/1.1"

<Connector port="8009" protocol="AJP/1.3"

修改这三个端口

保存,重启tomcat