一、修改tomcat的conf目录下的server.xml
配置service 节点,有几个项目就相应的配置几个service 节点;
注意修改Service name; Connector port; Engine name; Host appBase
<?xml version='1.0' encoding='utf-8'?>
<Server port="8054" shutdown="SHUTDOWN">
<!-- Security listener. Documentation at /docs/config/listeners.html
<Listener className="org.apache.catalina.security.SecurityListener" />
-->
<!--APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
<Listener className="org.apache.catalina.core.JasperListener" />
<!-- Prevent memory leaks due to use of particular java/javax APIs-->
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<Service name="Catalina1">
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="9543" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina1" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps1"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
<Context path="/route" reloadable="true" docBase="/home/develop/tomcat-7.0.54/flatrass"/>
</Host>
</Engine>
</Service>
<Service name="Catalina2">
<!--把port改成8081-->
<Connector port="8081" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="9543" /> <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina2" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps2" ---这里要修改为修改后的webapps名称
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
<Context path="/route" reloadable="true" docBase="/home/develop/tomcat-7.0.54/flatrasweats"/>
</Host>
</Engine>
</Service>
</Server>
二、先依照此配置文件配置,完成后在tomcat根目录下复制文件夹webapps,粘贴重命名为webapps1,webapps2,如下图:此文件夹就是分别用来部署项目的。
三、在tomcat根目录下的conf文件中,复制conf文件夹下的Catalina文件夹,粘贴并重命名为Catalina1,Catalina2,如图:
配置完成,现在可以把项目分别部署到配置好的两个文件夹webapps1和webapps2中;
启动tomcat,分别用不同的端口号8080和8081测试;
http://127.0.0.1:8080/项目名http://127.0.0.1:8081/项目名