Tomcat variety of ways to deploy multiple projects

Tomcat deployment with a number of projects with a port

To lay on the war package as webapps following: HelloApp1.war. If the Figure:

1571887773(1).jpg

Start tomcat, found in webapps following more than a HelloApp1 folder

1571887978.jpg

HelloApp1.war is packed with SpringBoot project from the execution method is http: // localhost: 9001 / emp / demo but should actually go http: // localhost: 8080 / HelloApp1 / emp / demo

With more than one port Tomcat deploy multiple projects

Common sense several parameters:

<Connector port=“8080” protocol=“HTTP/1.1” connectionTimeout=“60000”

redirectPort=“8443” disableUploadTimeout=“false”

executor=“tomcatThreadPool” URIEncoding=“UTF-8”/>

Where 8080 is the HTTP port 8443 for the HTTPS port.

8005 port for remote service stop

8009 is the AJP port, APACHE TOMCAT can access over 8009 AJP protocol port.

  1. Conf server.xml file following modifications:
    copying a-Service, modify the corresponding parameter code comments. If you do not comment out the report will address occupied.
<?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
 -->
 <!--8005为远程停服务端口 -->
<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>

  <!--第一个服务服务名为Catalina -->
  <Service name="Catalina">
  <!--8080为Http端口 8443为Https端口 -->
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               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>
   <!--第二个服务服务名为Catalina1 -->
  <Service name="Catalina1">

    <Connector port="8888" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
 
 

    <Engine name="Catalina1" defaultHost="localhost">

      <Realm className="org.apache.catalina.realm.LockOutRealm">

        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>

      <Host name="localhost"  appBase="webapps1"
            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>

  1. Copy the file in the conf Catalina renamed Catalina1 (to the new service node configuration is consistent).

1571897606(1).jpg

  1. Copy the folder in the webapps directory tomcat, renamed webapps1. Is then placed under the corresponding .war webapps1 directory (to the new service node configuration consistent).

1571897985.jpg

In turn visit http: // localhost: 8888 / emp / demo, http: // localhost: 8080 / is OK to.

A computer to configure multiple tomcat service.

The first configuration do not have to make changes, then we copy the first tomcat folder, the folder named as follows:

1571904244(1).jpg

Environment variables are configured as two tomcat:

1571904351(1).jpg

  1. Then add the path% CATALINA_HOME% \ bin;% CATALINA_HOME2% \ bin; longitudinal separated by commas.

  2. Then all CATALINA_HOME startup.bat, shutdown.bat, service.bat, catalina.bat these four files in the bin directory of tomcat9090 into CATALINA_HOME2, CATALINA_BASE into CATALINA_BASE2.

  3. Then modify the server.xml conf folder.
    , port changed to 8006, the conflict can not

    be 8080 to 9090, can not conflict
    , portt changed 8019,8029,8039, can not conflict

  4. Respectively, into tomcat8080, tomcat9090 folder under bin directory, run the install command
    the service.bat install Tomcat8080
    the service.bat install Tomcat9090

Uninstall command
service.bat remove Tomcat9090 or sc delete Tomcat9090

Refresh the list of services you can see the corresponding service.

reference:

tomcat environment variable configuration

A number of projects deployed under tomcat server deployment or a multiple tomcat

Published 152 original articles · won praise 18 · views 70000 +

Guess you like

Origin blog.csdn.net/tanhongwei1994/article/details/102726245