米鼠商城

多快好省,买软件就上米鼠网

最新项目

人才服务

靠谱的IT人才垂直招聘平台

tomcat8配置虚拟目录,实现一个tomcat运行两个项目, tomcat配置URL不区分大小写

  • lkj155
  • 2
  • 2020-07-13 20:02

精选30+云产品,助力企业轻松上云!>>>

<?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">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
  <!-- Security listener. Documentation at /docs/config/listeners.html
  <Listener className="org.apache.catalina.security.SecurityListener" />
  -->
  <!--APR library loader. Documentation at /docs/apr.html -->
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

  <!-- 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
   -->
   
   <!-- 第一个tomcat--->
  <Service name="Catalina">

    
    <Connector port="8989" protocol="HTTP/1.1"   maxPostSize="1002400"  maxHttpHeaderSize ="1002400"   
               connectionTimeout="20000"
               redirectPort="8443" />
   
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


    
    <Engine name="Catalina" defaultHost="localhost">
     
      <Realm className="org.apache.catalina.realm.LockOutRealm">
       
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>

      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">	 


        
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

      </Host>
    </Engine>
  </Service>
  
   <!-- 第2个tomcat--->
  
    <Service name="Catalina">

    
    <Connector port="80" protocol="HTTP/1.1"   maxPostSize="1002400"  maxHttpHeaderSize ="1002400"   
               connectionTimeout="20000"
               redirectPort="8443" />
   
    <Connector port="8011" protocol="AJP/1.3" redirectPort="8443" />


    
    <Engine name="Catalina" defaultHost="localhost">
     
      <Realm className="org.apache.catalina.realm.LockOutRealm">
       
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>

      <Host name="localhost"  appBase="webapps2"
            unpackWARs="true" autoDeploy="true">	 


        
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

      </Host>
    </Engine>
  </Service>
  
</Server>

一般都知道tomcat两个端口不一样

还有另外一个协议端口

   <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

    <Connector port="8011" protocol="AJP/1.3" redirectPort="8443" />

是不能相同的。

 

 

 <Host name="localhost"  appBase="webapps"             unpackWARs="true" autoDeploy="true"> 

      <Host name="localhost"  appBase="webapps2"             unpackWARs="true" autoDeploy="true">  

appBase表示目录,所以另外一个目录设置为  webapps2

没有测试上传文件是否会有影响,temp好像是共用一个

参考  https://blog.csdn.net/yx0628/article/details/21956465

https://blog.csdn.net/myxx520/article/details/6902328

 

二、tomcat路径不区分大小写

tomcat 8 下是修改文件 apache-tomcat-8.5.34\conf\context.xml

在 Context 节点下 添加 

<Resources allowLinking="true" />
<Context>

    <!-- Default set of monitored resources. If one of these changes, the    -->
    <!-- web application will be reloaded.                                   -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
    <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
    <Resources allowLinking="true" />
    <!-- Uncomment this to disable session persistence across Tomcat restarts -->
    <!--
    <Manager pathname="" />
    -->
</Context>

 

Resources 节点还可以设置其他属性

<Resources allowLinking="true" cachingAllowed="true" cacheMaxSize="100000" />

官网文档:https://tomcat.apache.org/tomcat-8.0-doc/config/resources.html

参考:http://blog.sqber.com/articles/tomcat-set-url-case-insensitive.html



这里给大家推荐一个在线软件复杂项交易平台:米鼠网 https://www.misuland.com

米鼠网自成立以来一直专注于从事软件项目人才招聘软件商城等,始终秉承“专业的服务,易用的产品”的经营理念,以“提供高品质的服务、满足客户的需求、携手共创双赢”为企业目标,为中国境内企业提供国际化、专业化、个性化、的软件项目解决方案,我司拥有一流的项目经理团队,具备过硬的软件项目设计和实施能力,为全国不同行业客户提供优质的产品和服务,得到了客户的广泛赞誉。



如有侵权请联系邮箱(service@misuland.com)

猜你喜欢

评论留言