Tomcat下为每个Web应用配置不同的访问端口


在server.xml中配置两个service为Catalina.app1和Catalina.app2

 <Service name="Catalina.app1">
    <Connector connectionTimeout="20000" port="8081" protocol="HTTP/1.1" redirectPort="8443"/>
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>
    <Engine defaultHost="localhost" name="Catalina.app1"> 
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
      </Realm>
      <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true"> 
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t &quot;%r&quot; %s %b" prefix="localhost_access_log." suffix=".txt"/>
      <Context docBase="D:\Program Files\apache-tomcat-7.0.62\webapps\test" path="" reloadable="true" source="org.eclipse.jst.jee.server:test"/></Host>
    </Engine>
  </Service>
  
  
  
  
  <Service name="Catalina.app2">
    <Connector connectionTimeout="20000" port="8082" protocol="HTTP/1.1" redirectPort="8443"/>
    <Connector port="8010" protocol="AJP/1.3" redirectPort="8443"/>
    <Engine defaultHost="localhost" name="Catalina.app2"> 
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
      </Realm>
      <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true"> 
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t &quot;%r&quot; %s %b" prefix="localhost_access_log." suffix=".txt"/>
     <Context docBase="D:\Program Files\apache-tomcat-7.0.62\webapps\springmvc_hello" path="/springmvc_hello" reloadable="true" source="org.eclipse.jst.jee.server:springmvc_hello"/></Host>
    </Engine>
  </Service>


配置后启动tomcat

wKiom1YjeYrQBHrwAAIZcVQIwyA451.jpg


参考文章:

http://wenku.baidu.com/link?url=CDX6-xdricOb_nrCqJj7GTPa3lu_tmg9DE5-SX6ZiSNidAtcqQwjniKeXgdTDAWx-R6iLlJVqTvJDIzlshhJIxvCqcTJFFh_13p_aoxMqm3


http://www.linuxidc.com/Linux/2012-06/62032p2.htm


你可能感兴趣的:(tomcat不同端口不同应用)