一个tomcat部署多个项目

同一个tomcat部署多个项目可以有两种方式

方式一:

修改server.xml文件,一个tomcat监听多个端口,指向多个程序文件目录。

下边为一个完整的配置

<?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" />

  <Service name="h5">
    <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
    <Connector port="8081" protocol="AJP/1.3" redirectPort="8443" />
    <Engine name="h5" defaultHost="managehost">
      <Host name="h5host" appBase="ys-gzpso-web" unpackWARs="true" autoDeploy="true">
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="gzpso_access_log" suffix=".txt" pattern="%h %l %u %t "%r&quo
t; %s %b" />
      </Host>
    </Engine>
  </Service>

  <Service name="manage">
    <Connector port="8082" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8444" />
    <Connector port="8083" protocol="AJP/1.3" redirectPort="8444" />
    <Engine name="manage" defaultHost="operationhost">
      <Host name="managehost" appBase="ys-gzpso-manage-web" unpackWARs="true" autoDeploy="true">
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="gzpso-manage_access_log" suffix=".txt" pattern="%h %l %u %t "
;%r" %s %b" />
      </Host>
    </Engine>
  </Service>
</Server>

然后将war放在如下位置

$tomcatHOME/ys-gzpso-web/ROOT.war

$tomcatHOME/ys-gzpso-manage-web/ROOT.war


方法二:

修改server.xml,配置Context节点,部分代码如下,监听的是同样一个端口,不同的目录

<Context path="/manage" docBase="war文件目录解压目录t" debug="0" privileged="true"></Context>

<Context path="/h5“ reloadable="true" docBase="war文件目录解压目录" workDir="工作目录"/>




发布了19 篇原创文章 · 获赞 16 · 访问量 14万+

猜你喜欢

转载自blog.csdn.net/u010884123/article/details/77969585