第一步:条件:配置好jdk,如果没有配置好请看:https://www.cnblogs.com/weibanggang/p/11460537.html
下载tomcat到服务器中,并解压到文件夹,如/home/tomcat/tomcat1
再复制一份tomcat压缩包,解压到 /home/tomcat/tomcat2
如下是我的tomcat
复制命令:
cp -r /home/tomcat/tomcat8.5_1 /home/tomcat/tomcat8.5_2
同样是操作/etc/profile 文件。
#vi /etc/profile
然后在文件最后一行,即刚刚添加JDK环境变量的后边添加如下配置:
#tomcat1 export CATALINA_HOME1=/home/tomcat/tomcat8.5_1 export CATALINA_BASE1=/home/tomcat/tomcat8.5_1 export TOMCAT_HOME1=/home/tomcat/tomcat8.5_1 #tomcat2 export CATALINA_HOME2=/home/tomcat/tomcat8.5_2 export CATALINA_BASE2=/home/tomcat/tomcat8.5_2 export TOMCAT_HOME2=/home/tomcat/tomcat8.5_2 #tomcat3 export CATALINA_HOME3=/home/tomcat/tomcat8.5_3 export CATALINA_BASE3=/home/tomcat/tomcat8.5_3 export TOMCAT_HOME3=/home/tomcat/tomcat8.5_3 #tomcat4 export CATALINA_HOME4=/home/tomcat/tomcat8.5_4 export CATALINA_BASE4=/home/tomcat/tomcat8.5_4 export TOMCAT_HOME4=/home/tomcat/tomcat8.5_4 #tomcat5 export CATALINA_HOME5=/home/tomcat/tomcat8.5_5 export CATALINA_BASE5=/home/tomcat/tomcat8.5_5 export TOMCAT_HOME5=/home/tomcat/tomcat8.5_5 #tomcat6 export CATALINA_HOME6=/home/tomcat/tomcat8.5_6 export CATALINA_BASE6=/home/tomcat/tomcat8.5_6 export TOMCAT_HOME6=/home/tomcat/tomcat8.5_6
(注意:tomcat123456中的配置命名)
添加后,ctrl+C, 然后命令行输入 :wq ,保存退出。加载环境变量,命名行:
source /etc/profile
<Server port="8001" shutdown="SHUTDOWN"> <Listener className="org.apache.catalina.startup.VersionLoggerListener" /> <!-- Security listener. Documentation at /docs/config/listeners.html -->
<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
<!-- Define an AJP 1.3 Connector on port 8009 --> <Connector port="8010" protocol="AJP/1.3" redirectPort="8443" />
1、修改Server prot 默认为8005--》修改为8002
<Server port="8002" shutdown="SHUTDOWN"> <Listener className="org.apache.catalina.startup.VersionLoggerListener" /> <!-- Security listener. Documentation at /docs/config/listeners.html
<Connector port="82" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
<!-- Define an AJP 1.3 Connector on port 8009 --> <Connector port="8011" protocol="AJP/1.3" redirectPort="8443" />
命令: vi tomcat8.5_1/bin/startup.sh
加入:
export CATALINA_BASE=$CATALINA_BASE1 export CATALINA_HOME=$CATALINA_HOME1 export TOMCAT_HOME=TOMCAT_HOME1

命令: vi tomcat8.5_1/bin/shutdown.sh
加入:
export CATALINA_BASE=$CATALINA_BASE1 export CATALINA_HOME=$CATALINA_HOME1 export TOMCAT_HOME=TOMCAT_HOME1
1、tomcat2/bin/startup.sh 命令: vi tomcat8.5_2/bin/startup.sh 加入: export CATALINA_BASE=$CATALINA_BASE2 export CATALINA_HOME=$CATALINA_HOME2 export TOMCAT_HOME=TOMCAT_HOME22、tomcat2/bin/shutdown.sh 命令: vi tomcat8.5_2/bin/shutdown.sh 加入: export CATALINA_BASE=$CATALINA_BASE2 export CATALINA_HOME=$CATALINA_HOME2 export TOMCAT_HOME=TOMCAT_HOME2
分别启动tomcat中的 /bin/startup.sh ,然后打开浏览器访问测试。
原文:https://www.cnblogs.com/weibanggang/p/11460665.html