Tomcat配置多个端口号或多个应用,使得域名后面加不同端口访问

1.一个Tomcat下配置多个端口号,这里是针对一个应用服务而言,只需在Service下配置多个<Connector>。如下:

<Server port="8005" shutdown="SHUTDOWN" debug="0"> <Service name="Catalina">
    <Connector
        port="8089" maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               debug="0" connectionTimeout="20000" URIEncoding="utf-8"
               disableUploadTimeout="true" />
    <Connector port="8009"
               enableLookups="false" redirectPort="8443" debug="0"
               protocol="AJP/1.3" />
     
<Connector port="8099" protocol="HTTP/1.1" maxThreads="150" minSpareThreads="25"         maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               debug="0" connectionTimeout="20000" URIEncoding="utf-8"
               disableUploadTimeout="true" />
    <Engine name="Catalina" defaultHost="localhost" debug="0">
              <Host name="localhost" debug="0" appBase="webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">
              </Host>
    </Engine>
</Service>
</Server>

在这个应用里,可以用8089端口号访问服务,也可以用8099端口号来访问服务;

(注:这里的Host中没有配置context内容,是通过D:\Java\Tomcat 5.0\conf\Catalina\localhost下的一个*.xml指定的)这里的*.xml的内容如下:

<Context displayName="dmis" docBase="D:/IBM/workspace/dmisArea/WebRoot" path="/dmis" privileged="true" workDir="work\Catalina\localhost\dmis">
</Context>

2.在一个Tomcat下配置多个服务,用不同的端口号。

<Server port="8005" shutdown="SHUTDOWN" debug="0">
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
            debug="0"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
            debug="0"/>
<GlobalNamingResources>
    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>

    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
       description="User database that can be updated and saved">
    </Resource>
    <ResourceParams name="UserDatabase">
      <parameter>
        <name>factory</name>
        <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
      </parameter>
      <parameter>
        <name>pathname</name>
        <value>conf/tomcat-users.xml</value>
      </parameter>
    </ResourceParams>

</GlobalNamingResources>

<Service name="Catalina">
    <Connector
     port="8089" maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               debug="0" connectionTimeout="20000" URIEncoding="utf-8"
               disableUploadTimeout="true" />
    <Connector port="8009"
               enableLookups="false" redirectPort="8443" debug="0"
               protocol="AJP/1.3" />
     
<Connector port="8099" protocol="HTTP/1.1" maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               debug="0" connectionTimeout="20000" URIEncoding="utf-8"
               disableUploadTimeout="true" />
    <Engine name="Catalina" defaultHost="localhost" debug="0">
      <Logger className="org.apache.catalina.logger.FileLogger"
              prefix="catalina_log." suffix=".txt"
              timestamp="true"/>
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
                 debug="0" resourceName="UserDatabase"/>
      <Host name="localhost" debug="0" appBase="webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">
        <Logger className="org.apache.catalina.logger.FileLogger"
                 directory="logs" prefix="localhost_log." suffix=".txt"
            timestamp="true"/>
      </Host>
    </Engine>
</Service><Service name="webportal">
<Connector port="8090" protocol="HTTP/1.1" maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               debug="0" connectionTimeout="20000" URIEncoding="utf-8"
               disableUploadTimeout="true" />
<Engine name="myengine" defaultHost="myhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
     resourceName="UserDatabase"/>

<Host name="myhost" appBase="webapplrm"
     unpackWARs="true" autoDeploy="true"
     xmlValidation="false" xmlNamespaceAware="false">
   <Context displayName="pow2org" docBase="D:\IBM\workspace\pow2org\WebRoot" path="/pow2org" privileged="true" workDir="work\myengine\localhost\pow3org">
   </Context>
</Host>
</Engine>
</Service>

</Server>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值