前几天开发需求单台linux安装多个tomcat,研究了下,配置如下
1,在/usr/local/下部署两个tomcat7,tomcat8 。两个版本不一样哦。
2,修改/etc/profile文件,加入下面内容
vi /etc/profile
export JAVA_HOME=/usr/java/jdk1.8.0_92
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=$JAVA_HOME/jre/lib/ext:$JAVA_HOME/lib/tools.jar
export PATH JAVA_HOME CLASSPATH
####tomcat7
TOMCAT_HOME=/usr/local/tomcat7/
CATALINA_HOME=/usr/local/tomcat7/
CATLINA_BASE=/usr/local/tomcat7/
export TOMCAT_HOME CATALINA_HOME CATALINA_BASH
####tomcat8
TOMCAT_HOME_1=/usr/local/tomcat8/
CATALINA_HOME_1=/usr/local/tomcat8/
CATLINA_BASE_1=/usr/local/tomcat8/
export TOMCAT_HOME_1 CATALINA_HOME_1 CATALINA_BASH_1
TOMCAT_HOME=/usr/local/tomcat7
export TOMCAT_HOME
TOMCAT_HOME_1=/usr/local/tomcat8
export TOMCAT_HOME_1
3,修改tomcat配置文件 ,
tomcat7保持不变;
修改tomcat8配置如下:
在/usr/local/tomcat8/bin下,修改startup.sh 和 shutdown.sh 两个文件,在文件#!/bin/sh下面入如下:
export JAVA_HOME=/usr/java/jdk1.8.0_92/
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib:$JAVA_HOME/bin
export CATALINA_HOME=$CATALINA_HOME_1
export CATLINA_BASE=$CATLINA_BASE_1
4,修改tomcat8/conf/server.xml 文件,
<Server port="8006" shutdown="SHUTDOWN"> #将原8005改为8006
<Connector port="8083" maxHttpHeaderSize="8192" #将8080改为8083
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="120000" disableUploadTimeout="true" URIEncoding="UTF-8" />
<Connector port="8010" protocol="AJP/1.3" redirectPort="8443" /> ##将8009改为8010
<Engine name="Test" defaultHost="Test">
5,重启tomcat。
/usr/loca/tomcat7/bin/startup.sh
/usr/loca/tomcat8/bin/startup.sh
访问地址http://192.168.153.153:8080 http://192.168.153.153:8083