码迷,mamicode.com
首页 > 其他好文 > 详细

tomcat基于多端口的虚拟主机配置

时间:2015-08-11 12:28:07      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:

我又有两个项目需要部署在一台机器上,两个项目对应两个不同的服务,一个服务启动侦听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)

tomcat基于多端口的虚拟主机配置

标签:

原文地址:http://my.oschina.net/u/2420214/blog/490634

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!