我又有两个项目需要部署在一台机器上,两个项目对应两个不同的服务,一个服务启动侦听8001 另一个侦听8002端口,就是基于多端口的虚拟机主机配置,只需要更改tomcat目录下的conf/server.xml配置文件,内容如下:
<?xml version=‘1.0‘ encoding=‘utf-8‘?> <Server port="8005" shutdown="SHUTDOWN"> <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /> <Listener className="org.apache.catalina.core.JasperListener" /> <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /> <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" /> <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> <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> <!-- 应用1 个人中心wap版--> <Service name="Catalina1"> <Connector port="8001" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> <Engine name="Catalina1" defaultHost="localhost"> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> <Host name="localhost" appBase="webapps1" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Context reloadable="true" docBase="/usr/local/tomcat/webapps1/imsswap" path=""/> </Host> </Engine> </Service> <!-- 应用2 商城wap版--> <Service name="Catalina2"> <Connector port="8002" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> <Engine name="Catalina2" defaultHost="localhost"> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> <Host name="localhost" appBase="webapps2" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Context reloadable="true" docBase="/usr/local/tomcat/webapps2/shopwap" path=""/> </Host> </Engine> </Service> </Server>
然后启动tomcat就行了。(本次测试的tomcat版本为1.6.x jdk版本1.6.x)
时间: 2024-11-05 20:31:04