//结合博主之前的安装tomcat的博文一起看,tomcat多实例就是在不同路径启动多个tomcat,然后在本机不同端口启动

[root@ycj ~]# cd /usr/local/src/

[root@ycj src]# cp -r apache/ apache2 //复制原来的tomcat文件到新目录

[root@ycj src]# vi /etc/profile //配置环境变量
CATALINA_BASE=/usr/local/src/apache
CATALINA_HOME=/usr/local/src/apache
TOMCAT_HOME=/usr/local/src/apache
export CATALINA_BASE CATALINA_HOME TOMCAT_HOME

CATALINA_2_BASE=/usr/local/src/apache2
CATALINA_2_HOME=/usr/local/src/apache2
TOMCAT_2_HOME=/usr/local/src/apache2
export CATALINA_2_BASE CATALINA_2_HOME TOMCAT_2_HOME

[root@ycj src]# source /etc/profile //刷新

[root@ycj src]# cd apache2/bin
[root@ycj bin]# vi catalina.sh //切换到bin目录下修改
 # OS specific support.  $var _must_ be set to either true or false.
在下面增加如下代码
export CATALINA_BASE=$CATALINA_2_BASE
export CATALINA_HOME=$CATALINA_2_HOME

==修改端口==
[root@ycj bin]# cd ..
[root@ycj apache2]# cd conf/
[root@ycj conf]# vim server.xml
修改server.xml配置和第一个不同的启动、关闭监听端口。
修改后示例如下:
 <Server port="9005" shutdown="SHUTDOWN">               端口:8005->9005
<!-- Define a non-SSL HTTP/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 AJP 1.3 Connector on port 8009 -->
    <Connector port="9009"                                  端口:8009->9009
               enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />

==启动并访问==
[root@ycj conf]# cd ..
[root@ycj apache2]# cd bin/
[root@ycj bin]# ./startup.sh
//两个tomcat都要启动

tomcat多实例-LMLPHPtomcat多实例-LMLPHP

tomcat多实例-LMLPHPtomcat多实例-LMLPHP

05-11 19:40