zoukankan      html  css  js  c++  java
  • Tomcat下部署多个项目

    转载地址:http://blog.csdn.net/philosophyatmath/article/details/30246631

    同一端口号的多个项目部署

        添加:

     
    1. <Context path="/route" reloadable="true" docBase="/home/develop/tomcat-7.0.54/flatrass"/>  
    2. <Context path="/route2" reloadable="true" docBase="/home/develop/tomcat-7.0.54/flatrasweats"/>  

    通过访问:http://127.0.0.1:8080/route  http://127.0.0.1:8080/route2 对应各子的项目

     

    对应不同端口号的多个项目部署

    通过访问:http://127.0.0.1:8080/route  http://127.0.0.1:8081/route 对应各子的项目        
            打开conf文件夹server.xml文件,添加

    [html] view plain copy
     
     在CODE上查看代码片派生到我的代码片
    1. <Context path="/route" reloadable="true" docBase="/home/develop/tomcat-7.0.54/flatrass"/>  


            在service标签下面写一个service标签。复制上面service,再修改里面的端口号为8081。添加:

    [html] view plain copy
     
     在CODE上查看代码片派生到我的代码片
    1. <Context path="/route" reloadable="true" docBase="/home/develop/tomcat-7.0.54/flatrasweats"/>  
    [html] view plain copy
     
     在CODE上查看代码片派生到我的代码片
    1. <?xml version='1.0' encoding='utf-8'?>  
    2.   
    3. <Server port="8054" shutdown="SHUTDOWN">  
    4.   <!-- Security listener. Documentation at /docs/config/listeners.html  
    5.   <Listener className="org.apache.catalina.security.SecurityListener" />  
    6.   -->  
    7.   <!--APR library loader. Documentation at /docs/apr.html -->  
    8.   <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />  
    9.   <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->  
    10.   <Listener className="org.apache.catalina.core.JasperListener" />  
    11.   <!-- Prevent memory leaks due to use of particular java/javax APIs-->  
    12.   <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />  
    13.   <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />  
    14.   <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />  
    15.   
    16.    
    17.   <GlobalNamingResources>  
    18.    
    19.     <Resource name="UserDatabase" auth="Container"  
    20.               type="org.apache.catalina.UserDatabase"  
    21.               description="User database that can be updated and saved"  
    22.               factory="org.apache.catalina.users.MemoryUserDatabaseFactory"  
    23.               pathname="conf/tomcat-users.xml" />  
    24.   </GlobalNamingResources>  
    25.   
    26.   
    27.   <Service name="Catalina">  
    28.   
    29.   
    30.     <Connector port="8080" protocol="HTTP/1.1"  
    31.                connectionTimeout="20000"  
    32.                redirectPort="9543" />  
    33.   
    34.      
    35.     <Connector port="8909" protocol="AJP/1.3" redirectPort="9543" />  
    36.   
    37.     <Engine name="Catalina" defaultHost="localhost">  
    38.   
    39.       <Realm className="org.apache.catalina.realm.LockOutRealm">  
    40.    
    41.         <Realm className="org.apache.catalina.realm.UserDatabaseRealm"  
    42.                resourceName="UserDatabase"/>  
    43.       </Realm>  
    44.   
    45.       <Host name="localhost"  appBase="webapps"  
    46.             unpackWARs="true" autoDeploy="true">  
    47.   
    48.         <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"  
    49.                prefix="localhost_access_log." suffix=".txt"  
    50.                pattern="%h %l %u %t "%r" %s %b" />  
    51.     <Context path="/route" reloadable="true" docBase="/home/develop/tomcat-7.0.54/flatrass"/>  
    52.       </Host>     
    53.     </Engine>  
    54.     </Service>  
    55.     
    56.      <Service name="Catalina">  
    57.      <!--把port改成8081-->  
    58.     <Connector port="8081" protocol="HTTP/1.1"  
    59.                connectionTimeout="20000"  
    60.                redirectPort="9543" />  
    61.     
    62.     <Connector port="8909" protocol="AJP/1.3" redirectPort="9543" />  
    63.     <Engine name="Catalina" defaultHost="localhost">  
    64.       <Realm className="org.apache.catalina.realm.LockOutRealm">  
    65.         <Realm className="org.apache.catalina.realm.UserDatabaseRealm"  
    66.                resourceName="UserDatabase"/>  
    67.       </Realm>  
    68.       <Host name="localhost"  appBase="webapps"  
    69.             unpackWARs="true" autoDeploy="true">  
    70.         <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"  
    71.                prefix="localhost_access_log." suffix=".txt"  
    72.                pattern="%h %l %u %t "%r" %s %b" />  
    73.         <Context  path="/route" reloadable="true" docBase="/home/develop/tomcat-7.0.54/flatrasweats"/>  
    74.       </Host>  
    75.     </Engine>  
    76.   </Service>  
    77. </Server>  

    Java home set :

    setclasspath.sh

    export JAVA_HOME=/home/qatest/jdk1.8.0_91
    export JRE_HOME=/home/qatest/jdk1.8.0_91/jre

    web.xml的加载过程是:

    context-param -> listener -> filter -> servlet 

    其它:

    service httpd status
    service httpd restart
    lsof -i:80

    chmod +x catalina.sh
    ps –ef|grep tomcat
    rm –rf file

    启动tomcat #   ./startup.sh
    关闭tomcat #   ./shutdown.sh
    查看是否启动成功可以输入ps axuwf|grep java,如果出现一大堆结果,就是启动成功了.
    也可以netstat -lnpt,查看8088端口有没有被使用.如果被使用了,说明启动成功了.
  • 相关阅读:
    pzrNB!!!
    biu biu biu
    大笑三声再往下看!
    Selenium之Chrome浏览器的启动
    Selenium IDE脚本录制步骤简介
    Selenium IDE的一些操作
    Selenium IDE编辑区域修改操作学习
    在firefox安装Selenium IDE
    执行Java脚本firefox启动成功,不运行test方法,且提示NullPointerException
    Selenium+Python学习之一
  • 原文地址:https://www.cnblogs.com/ceshi2016/p/6031203.html
Copyright © 2011-2022 走看看