zoukankan      html  css  js  c++  java
  • tomcat6.0 配置不同端口访问不同项目

    <?xml version='1.0' encoding='utf-8'?>
    <!--
      Licensed to the Apache Software Foundation (ASF) under one or more
      contributor license agreements.  See the NOTICE file distributed with
      this work for additional information regarding copyright ownership.
      The ASF licenses this file to You under the Apache License, Version 2.0
      (the "License"); you may not use this file except in compliance with
      the License.  You may obtain a copy of the License at
    
          http://www.apache.org/licenses/LICENSE-2.0
    
      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.
    -->
    <!-- Note:  A "Server" is not itself a "Container", so you may not
         define subcomponents such as "Valves" at this level.
         Documentation at /docs/config/server.html
     -->
    <Server port="8005" shutdown="SHUTDOWN">
    
      <!--APR library loader. Documentation at /docs/apr.html -->
      <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
      <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
      <Listener className="org.apache.catalina.core.JasperListener" />
      <!-- Prevent memory leaks due to use of particular java/javax APIs-->
      <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
      <!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
      <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
      <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
    
      <!-- Global JNDI resources
           Documentation at /docs/jndi-resources-howto.html
      -->
      <GlobalNamingResources>
        <!-- Editable user database that can also be used by
             UserDatabaseRealm to authenticate users
        -->
        <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>
    
      <!-- A "Service" is a collection of one or more "Connectors" that share
           a single "Container" Note:  A "Service" is not itself a "Container", 
           so you may not define subcomponents such as "Valves" at this level.
           Documentation at /docs/config/service.html
       -->
       
      <Service name="Catalina">
      
            <Connector port="80" protocol="HTTP/1.1" 
                       connectionTimeout="20000" 
                       redirectPort="8443" />
           
            <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
    
    
            <Engine name="Catalina" defaultHost="localhost">
    
              <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
                     resourceName="UserDatabase"/>
    
              <Host name="localhost"  appBase="webapps"
                    unpackWARs="true" autoDeploy="true"
                    xmlValidation="false" xmlNamespaceAware="false">
                
                
              </Host>
            
            </Engine>
      </Service>  
      
    </Server>


    以上是默认Server.xml配置,默认项目物理路径:webapps/ROOT/

    访问地址类型:http://localhost/

    下面要增加一下带端口访问的项目例如:http://localhost:8088/,物理路径:webapps1/ROOT/

    步骤:

    1、增加一个Service节点,(直接复制原Service节点即可)

    2、修改新Service 节点中所有名称Catalina 修改为Catalina1(2处)

    3、复制一份conf下的Catalina文件夹 并命名为Catalina1

    4、修改新创建Service下Host节点的appBase属性对应物理路径webapps1

    5、在新创建Service下Host节点下增加节点以下节点:( docBase 指向新项目物理路径)

    <Context  path="/pm25" reloadable="true" docBase="D:\Tomcat\webapps1\ROOT"/>
              

    新节点配置如下:

     <Service name="Catalina1">
      
            <Connector port="8088" 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  path="/pm25" reloadable="true" docBase="D:\Tomcat\webapps1\ROOT"/>
              </Host>
            
            </Engine>
      </Service>

    完整配置如下:

    <?xml version='1.0' encoding='utf-8'?>
    <!--
      Licensed to the Apache Software Foundation (ASF) under one or more
      contributor license agreements.  See the NOTICE file distributed with
      this work for additional information regarding copyright ownership.
      The ASF licenses this file to You under the Apache License, Version 2.0
      (the "License"); you may not use this file except in compliance with
      the License.  You may obtain a copy of the License at
    
          http://www.apache.org/licenses/LICENSE-2.0
    
      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.
    -->
    <!-- Note:  A "Server" is not itself a "Container", so you may not
         define subcomponents such as "Valves" at this level.
         Documentation at /docs/config/server.html
     -->
    <Server port="8005" shutdown="SHUTDOWN">
    
      <!--APR library loader. Documentation at /docs/apr.html -->
      <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
      <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
      <Listener className="org.apache.catalina.core.JasperListener" />
      <!-- Prevent memory leaks due to use of particular java/javax APIs-->
      <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
      <!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
      <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
      <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
    
      <!-- Global JNDI resources
           Documentation at /docs/jndi-resources-howto.html
      -->
      <GlobalNamingResources>
        <!-- Editable user database that can also be used by
             UserDatabaseRealm to authenticate users
        -->
        <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>
    
      <!-- A "Service" is a collection of one or more "Connectors" that share
           a single "Container" Note:  A "Service" is not itself a "Container", 
           so you may not define subcomponents such as "Valves" at this level.
           Documentation at /docs/config/service.html
       -->
       
      <Service name="Catalina">
      
            <Connector port="80" protocol="HTTP/1.1" 
                       connectionTimeout="20000" 
                       redirectPort="8443" />
           
            <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
    
    
            <Engine name="Catalina" defaultHost="localhost">
    
              <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
                     resourceName="UserDatabase"/>
    
              <Host name="localhost"  appBase="webapps"
                    unpackWARs="true" autoDeploy="true"
                    xmlValidation="false" xmlNamespaceAware="false">
                
                
              </Host>
            
            </Engine>
      </Service>
      <Service name="Catalina1">
      
            <Connector port="8088" 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  path="/pm25" reloadable="true" docBase="D:\Tomcat\webapps1\ROOT"/>
              </Host>
            
            </Engine>
      </Service>
      
        
      
    </Server>
  • 相关阅读:
    JavaScript getElementByID() not working
    [转] 从此不再惧怕URI编码:JavaScript及C# URI编码详解
    win 8.1 突然没有了声音 -- 解决办法
    升级打怪第一天 -------字符串重复
    Flex布局
    HTML 的全局事件属性
    CSS position 相对定位和绝对定位
    将1100秒转换为分秒格式
    新手小白的上路之旅
    谈谈我对Manacher算法的理解
  • 原文地址:https://www.cnblogs.com/lvlv/p/4608300.html
Copyright © 2011-2022 走看看