步骤如下:
(1)修改/etc/profile文件。添加一组java环境变量,和两组CATALINA环境变量(我没有进行此步骤的设置,可能因为我的Tomcat是免安装版的吧)记得修改完要使其生效,用命令:source /etc/profile
JAVA_HOME=/usr/java/jdk1.7.0
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME
export PATH
export CLASSPATH
CATALINA_BASE=/usr/local/apache-tomcat-6.0.35 -----tomcat路径
CATALINA_HOME=/usr/local/apache-tomcat-6.0.35
export CATALINA_BASE CATALINA_HOME
CATALINA_2_BASE=/usr/local/apache-tomcat-6.0.35-second
CATALINA_2_HOME=/usr/local/apache-tomcat-6.0.35-second
export CATALINA_2_BASE CATALINA_2_HOME
TOMCAT_HOME=/usr/local/apache-tomcat-6.0.35
export TOMCAT_HOME
TOMCAT_2_HOME=/usr/local/apache-tomcat-6.0.35-second
export TOMCAT_2_HOME
(2)打开tomcat/bin/catalina.sh ,找到下面红字,在下面增加如下代码;
# OS specific support. $var _must_ be set to either true or false.
# myself : add
export CATALINA_BASE=$CATALINA_2_BASE
export CATALINA_HOME=$CATALINA_2_HOME
#设置虚拟机参数
JAVA_OPTS="-server -Xms512m -Xmx512m -Xss512K -XX:PermSize=128m -XX:MaxPermSize=256m"
(3)把tomcat_2/conf下的server.xml打开,修改以下三个端口号:
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="60000" redirectPort="8443" disableUploadTimeout="false" executor="tomcatThreadPool" URIEncoding="UTF-8"/>
其中8080为HTTP端口,8443为HTTPS端口
<Server port="8005" shutdown="SHUTDOWN">
8005为远程停服务端口
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
8009为AJP端口,APACHE能过AJP协议访问TOMCAT的8009端口。