zoukankan      html  css  js  c++  java
  • tomcat多站点部署

    我们可能会有这种场景,一个tomcat想部署两个web工程,说白了就是公用一个端口,那怎么办呢?就是多站点部署,具体步骤如下(这里以linux平台举例):

    1)先修改server.xml(conf/server.xml)

      

     1  <!--For clustering, please take a look at documentation at:
     2           /docs/cluster-howto.html  (simple how to)
     3           /docs/config/cluster.html (reference documentation) -->
     4       <!--
     5       <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
     6       -->
     7 
     8       <!-- Use the LockOutRealm to prevent attempts to guess user passwords
     9            via a brute-force attack -->
    10       <Realm className="org.apache.catalina.realm.LockOutRealm">
    11         <!-- This Realm uses the UserDatabase configured in the global JNDI
    12              resources under the key "UserDatabase".  Any edits
    13              that are performed against this UserDatabase are immediately
    14              available for use by the Realm.  -->
    15         <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
    16                resourceName="UserDatabase"/>
    17       </Realm>
    18 
    19       <Host name="localhost"  appBase="webapps"
    20             unpackWARs="true" autoDeploy="true">
    21 
    22         <!-- SingleSignOn valve, share authentication between web applications
    23              Documentation at: /docs/config/valve.html -->
    24         <!--
    25         <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
    26         -->
    27 
    28         <!-- Access log processes all example.
    29              Documentation at: /docs/config/valve.html
    30              Note: The pattern used is equivalent to using pattern="common" -->
    31         <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
    32                prefix="localhost_access_log" suffix=".txt"
    33                pattern="%h %l %u %t &quot;%r&quot; %s %b" />
    34 
    35       </Host>
    36         <Host name="aa.com"  appBase="/data/aa/apache-tomcat-8.5.8/webapps/aa" unpackWARs="true" autoDeploy="true"></Host>
    37        <Host name="bb.com"  appBase="/data/bb/apache-tomcat-8.5.8/webapps/bb" unpackWARs="true" autoDeploy="true"></Host> 
    38    </Engine>

      ops:千万记得19-35行记得保留,不然war包不会解压,通过站点名或ip直接去访问会404.

      上面新增的两个host就是两个站点,aa和bb分别于不同的web工程。

    2)去conf/Catalina下创建相应的站点目录:

      

    mkdir -p conf/Catalina/aa.com
    mkdir -p conf/Catalina/bb.com
    这里的aa和bb对应上面server.xml host的name属性

    3)建立域名绑定:

      在/etc/hosts中加入域名映射

      

    127.0.0.1 localhost
    127.0.0.1 aa.com
    127.0.0.1 bb.com

    4)将war包上传至server.xml中host标签appBase对应的路径

    重启ok,完毕!

  • 相关阅读:
    窗口和消息
    输出文字
    《windows程序设计》第一章,建议想学API的每天看一章
    hdu 1008为何不对?求大神指导!
    课程设计(物体类),图片可能没有加载出来,自己运行一下就行了
    二叉树前序、中序、后序遍历相互求法
    哈希表工作原理
    c++中关于static关键字的问题
    Halcon学习笔记之缺陷检测(二)
    Halcon学习笔记之缺陷检测(一)
  • 原文地址:https://www.cnblogs.com/dbaxyx/p/6797363.html
Copyright © 2011-2022 走看看