• 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>
  • 相关阅读:
    关于JAVA的线程问题
    Java 对JTextField添加回车响应
    Failed to install *.apk on device 'emulator-5554': timeout .
    静态属性
    类与对象的实例属性

    面向对象2
    面向对象设计
    re模块,主要用来查询
    xml对标签操作,
  • 原文地址:https://www.cnblogs.com/lvlv/p/4608300.html
Copyright © 2020-2023  润新知