65424

Tomcat下部署多个项目

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

    添加:

[html] view plain copy     <ol class="dp-xml" start="1"><li class="alt"><Context path="/route" reloadable="true" docBase="/home/develop/tomcat-7.0.54/flatrass"/>  </li> <li><Context path="/route2" reloadable="true" docBase="/home/develop/tomcat-7.0.54/flatrasweats"/>  </li> </ol>

通过访问: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     <ol class="dp-xml" start="1"><li class="alt"><Context path="/route" reloadable="true" docBase="/home/develop/tomcat-7.0.54/flatrass"/>  </li> </ol>


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

[html] view plain copy     <ol class="dp-xml" start="1"><li class="alt"><Context path="/route" reloadable="true" docBase="/home/develop/tomcat-7.0.54/flatrasweats"/>  </li> </ol> [html] view plain copy     <ol class="dp-xml" start="1"><li class="alt"><?xml version='1.0' encoding='utf-8'?>  </li> <li>  </li> <li class="alt"><Server port="8054" shutdown="SHUTDOWN">  </li> <li>    <!-- Security listener. Documentation at /docs/config/listeners.html <Listener   </li> <li class="alt">        className="org.apache.catalina.security.SecurityListener" /> -->  </li> <li>    <!--APR library loader. Documentation at /docs/apr.html -->  </li> <li class="alt">    <Listener className="org.apache.catalina.core.AprLifecycleListener"  </li> <li>        SSLEngine="on" />  </li> <li class="alt">    <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->  </li> <li>    <Listener className="org.apache.catalina.core.JasperListener" />  </li> <li class="alt">    <!-- Prevent memory leaks due to use of particular java/javax APIs -->  </li> <li>    <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />  </li> <li class="alt">    <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />  </li> <li>    <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />  </li> <li class="alt">  </li> <li>  </li> <li class="alt">    <GlobalNamingResources>  </li> <li>  </li> <li class="alt">        <Resource name="UserDatabase" auth="Container"  </li> <li>            type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved"  </li> <li class="alt">            factory="org.apache.catalina.users.MemoryUserDatabaseFactory"  </li> <li>            pathname="conf/tomcat-users.xml" />  </li> <li class="alt">    </GlobalNamingResources>  </li> <li>  </li> <li class="alt">  </li> <li>    <Service name="Catalina">  </li> <li class="alt">  </li> <li>        <!--protocol 请使用nio2,或者apr -->  </li> <li class="alt">  </li> <li>        <Connector port="8080" protocol="HTTP/1.1"  </li> <li class="alt">            connectionTimeout="20000" redirectPort="9543" />  </li> <li>  </li> <li class="alt">  </li> <li>        <Connector port="8909" protocol="AJP/1.3" redirectPort="9543" />  </li> <li class="alt">  </li> <li>        <Engine name="Catalina" defaultHost="localhost">  </li> <li class="alt">  </li> <li>            <Realm className="org.apache.catalina.realm.LockOutRealm">  </li> <li class="alt">  </li> <li>                <Realm className="org.apache.catalina.realm.UserDatabaseRealm"  </li> <li class="alt">                    resourceName="UserDatabase" />  </li> <li>            </Realm>  </li> <li class="alt">  </li> <li>            <Host name="localhost" appBase="webapps" unpackWARs="true"  </li> <li class="alt">                autoDeploy="true">  </li> <li>  </li> <li class="alt">                <Valve className="org.apache.catalina.valves.AccessLogValve"  </li> <li>                    directory="logs" prefix="localhost_access_log." suffix=".txt"  </li> <li class="alt">                    pattern="%h %l %u %t "%r" %s %b"/>  </li> <li>                <Context path="/route" reloadable="true"  </li> <li class="alt">                    docBase="/home/develop/tomcat-7.0.54/flatrass" />  </li> <li>            </Host>  </li> <li class="alt">        </Engine>  </li> <li>    </Service>  </li> <li class="alt">  </li> <li>    <Service name="Catalina">  </li> <li class="alt">        <!--把port改成8081 -->  </li> <li>        <!--protocol 请使用nio2,或者apr -->  </li> <li class="alt">        <Connector port="8081" protocol="HTTP/1.1"  </li> <li>            connectionTimeout="20000" redirectPort="9543" />  </li> <li class="alt">        <Connector port="8909" protocol="AJP/1.3" redirectPort="9543" />  </li> <li>        <Engine name="Catalina" defaultHost="localhost">  </li> <li class="alt">            <Realm className="org.apache.catalina.realm.LockOutRealm">  </li> <li>                <Realm className="org.apache.catalina.realm.UserDatabaseRealm"  </li> <li class="alt">                    resourceName="UserDatabase" />  </li> <li>            </Realm>  </li> <li class="alt">            <Host name="localhost" appBase="webapps" unpackWARs="true"  </li> <li>                autoDeploy="true">  </li> <li class="alt">                <Valve className="org.apache.catalina.valves.AccessLogValve"  </li> <li>                    directory="logs" prefix="localhost_access_log." suffix=".txt"  </li> <li class="alt">                    pattern="%h %l %u %t "%r" %s %b"/>  </li> <li>                <Context path="/route" reloadable="true"  </li> <li class="alt">                    docBase="/home/develop/tomcat-7.0.54/flatrasweats" />  </li> <li>            </Host>  </li> <li class="alt">        </Engine>  </li> <li>    </Service>  </li> <li class="alt"></Server>  </li> </ol>

Java home set :setclasspath.shexport JAVA_HOME=/home/qatest/jdk1.8.0_91export JRE_HOME=/home/qatest/jdk1.8.0_91/jreweb.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端口有没有被使用.如果被使用了,说明启动成功了.

每天进步一点点

来源:博客园

作者:那些年的代码

链接:https://www.cnblogs.com/zhuyeshen/p/11425557.html

Recommend