一,配置多个tomcat
编辑环境变量:vi /etc/profile
#java环境配置
export JAVA_HOME=/usr/java/jdk1.7.0_71/
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
#tomcat配置
#tomcat1
export CATALINA_BASE=/usr/local/tomcat
export CATALINA_HOME=/usr/local/tomcat
export TOMCAT_HOME=/usr/local/tomcat
export PATH=$PATH:/usr/local/tomcat/bin
#tomcat2
export CATALINA_FAFA_1_BASE=/usr/local/tomcat_tata_1
export CATALINA_FAFA_1_HOME=/usr/local/tomcat_tata_1
export TOMCAT_FAFA_1_HOME=/usr/local/tomcat_tata_1
export PATH=$PATH:/usr/local/tomcat_tata_1/bin
来到第二个tomcat的bin目录下,在catalina.sh中加入
export JAVA_HOME=/usr/java/jdk1.7.0_71/
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
export CATALINA_BASE=$CATALINA_FAFA_1_BASE
export CATALINA_HOME=$CATALINA_FAFA_1_HOME
更改端口:
第一个tomcat,保持解压后的原状不用修改,
第二个tomcat,修改server.xml配置和第一个不同的启动、关闭监听端口。
修改后示例如下:
<Server port="9005"shutdown="SHUTDOWN"> 端口:8005->9005
<!-- Define a non-SSLHTTP/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" />
<!-- Define an AJP1.3 Connector on port 8009 -->
<Connector port="9009" 端口:8009->9009
enableLookups="false" redirectPort="8443"protocol="AJP/1.3" />