liunx下一个tomcat配置多个端口

一、Tomcat 安装后本身提供了一个server,端口配置默认是8080,对应目录为:..\Tomcat 6.0\webapps
二、Tomcat 6.0 配置多个端口,其实也就是给Tomcat增加几个server,并设置对应目录。下面以增加两个端口号为例
第一步、修改server.xml[..\Tomcat 6.0\conf]
(1)Tomcat提供的如下:

<Service name="Catalina">
 
    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
        maxThreads="150" minSpareThreads="4"/>
    -->
   
   
    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL HTTP/1.1 Connector on port 8080
    -->
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    -->          
    <!-- Define a SSL HTTP/1.1 Connector on port 8443
         This connector uses the JSSE configuration, when using APR, the
         connector should be using the OpenSSL style configuration
         described in the APR documentation -->
    <!--
    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html -->

    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">        
    -->
    <Engine name="Catalina" defaultHost="localhost">

      <!--For clustering, please take a look at documentation at:
          /docs/cluster-howto.html  (simple how to)
          /docs/config/cluster.html (reference documentation) -->
      <!--
      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
      -->       

      <!-- The request dumper valve dumps useful debugging information about
           the request and response data received and sent by Tomcat.
           Documentation at: /docs/config/valve.html -->
      <!--
      <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
      -->

      <!-- This Realm uses the UserDatabase configured in the global JNDI
           resources under the key "UserDatabase".  Any edits
           that are performed against this UserDatabase are immediately
           available for use by the Realm.  -->
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>

      <!-- Define the default virtual host
           Note: XML Schema validation will not work with Xerces 2.2.
       -->
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" 
prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
        -->
      </Host>
    </Engine>
  </Service>

(2)比着上面的葫芦画下面的瓢、新增两个端口号,注意Service name、Engine name、appBase,
当然了,端口号别忘了修改,以免重复。

<Service name="Catalina1"> 
     
    <Connector port="8091" maxHttpHeaderSize="8192" 
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75" 
               enableLookups="false" redirectPort="8443" acceptCount="100" 
               connectionTimeout="20000" disableUploadTimeout="true" /> 
      
    <Connector port="8009"   
               enableLookups="false" redirectPort="8443" protocol="AJP/1.3" /> 
 
 
    <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">                
      </Host> 
 
 
    </Engine> 
 
 
</Service>

<Service name="Catalina2"> 
     
    <Connector port="8092" maxHttpHeaderSize="8192" 
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75" 
               enableLookups="false" redirectPort="8443" acceptCount="100" 
               connectionTimeout="20000" disableUploadTimeout="true" /> 
     
    <Connector port="8009"   
               enableLookups="false" redirectPort="8443" protocol="AJP/1.3" /> 
 
 
    <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">                
      </Host> 
    </Engine>   
</Service>

第二步、创建相应的部署目录
..\Tomcat 6.0\webapps1
..\Tomcat 6.0\webapps2
同时可以将Tomcat 6.0\webapps下的有用的复制到新建的部署目录

第三步、创建配置文件目录和配置文件
..\Tomcat 6.0\conf\Catalina1\localhost
..\Tomcat 6.0\conf\Catalina2\localhost


host-manager.xml
manager.xml


配置文件的配置可参照..\Tomcat 6.0\conf\Catalina\localhost下的,只需要修改一下对应目录即可


大概的配置步骤就是这些,现在可以把不同的war包放在不同的位置来访问了
以上配置方法同样适合Tomcat 5.5

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值