This article understands how to deploy and start multiple Tomcat and migrate projects

Time:2021-11-28

Sometimes when we write a web project, several projects need to run at the same time, but there are always various problems when we directly place the war package. For example, multiple projects are deployed on the same port of the same tomcat, or multiple projects are deployed on multiple ports of the same Tomcat. After several tests, we decide to share with you. We won’t talk about the installation of JDK. Just configure the environment variables, Let’s introduce the detailed operation process:

Deploy Tomcat

1、 Download decompression

Download Tomcat from the official website and unzip it

2、 Modify profile

Open the conf directory

Modify the server.xml file and modify the HTTP access port (8080 port by default)


<Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" URIEncoding="UTF-8"/>

  <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"/>

It can be modified as (for reference only, according to personal needs):


<Connector port="8088" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" URIEncoding="UTF-8"/>

  <Connector executor="tomcatThreadPool"
               port="8088" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"/>

Change 8080 to the first port number that Tomcat is not using. The port number set here is the port number used when accessing the web in the future.

Modify the shutdown port (8005 port by default)


<Server port="8005" shutdown="SHUTDOWN" debug="0">

It can be modified as (for reference only, according to personal needs):


<Server port="8095" shutdown="SHUTDOWN" debug="0">

Change 8005 to a port number that is not in use

(3) Modify JVM boot port (8009 port by default)


<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

It can be modified as (for reference only, according to personal needs):


<Connector port="8099" protocol="AJP/1.3" redirectPort="8443" secretRequired="" />

Remember to remove the comment on this line and add it heresecretRequired=""The configuration of is very important, otherwise it will report the error of org.apache.catalina.lifecycleexception: protocol processor startup failure!!!

Change 8009 to a port number that is not in use

Modify logging.properties

In order to solve the Chinese garbled code output from the Tomcat console

Change UTF-8 in logging.properties to GBK

Run test

在这里插入图片描述

Migration project

1、 Package original project

If it is a maven project, first click the following command to execute install

在这里插入图片描述

Then, go to the directory of your Maven warehouse and find the packed package (you can go if you don’t know your warehouse directory)

As shown in the figure

在这里插入图片描述

Next, copy the package

在这里插入图片描述

2、 Copy to Tomcat

Then paste it under webapps of tomcat, as shown below

在这里插入图片描述

In this way, after Tomcat runs, it will automatically unzip it for you

3、 Visit try

在这里插入图片描述

end!!!

The above is the details of how to deploy and start multiple Tomcat and migrate projects. For more information about Tomcat deployment and startup, please pay attention to other related articles of developeppaer!