1 Background
Installed JDK1.8-u181 (actually, installing JRE is enough, but I have the JDK installation package on hand, why bother to download it) and Tomcat8.5.53.
After installation, JAVA_HOME and Path are configured in the environment variables. It is equipped with JRE, but not JDK.
To publish two war packages, MES and ERP.
2 Install Tomcat
I used .exe file to install it, and after installation, it did not have to be equipped with tomvat_home (because I don't know if it is necessary to configure it)
3 Copy the folder
3.1 Install directory confCatalina
Catalina is a folder, copy two copies of Catalina, one named CatalinaMES and the other named CatalinaERP, both placed in the installation directory\conf directory
3.2 Install directory webapps
webapps is also a folder, copy two copies, one named webappsMES and the other named webappsERP, both placed in the installation directory.
The war package that the MES project is used is placed under the installation directory\webappsMES
The war package used by the ERP project is placed under the installation directory\webappsERP
4 Modify the configuration file
Modify the contents in the installation directory\conf\
<?xml version="1.0" encoding="UTF-8"?> <Server port="-1" shutdown="SHUTDOWN"> <Listener className="" /> <Listener className="" SSLEngine="on" /> <Listener className="" /> <Listener className="" /> <Listener className="" /> <GlobalNamingResources> <Resource name="UserDatabase" auth="Container" type="" description="User database that can be updated and saved" factory="" pathname="conf/" /> </GlobalNamingResources> <!-- deploymes --> <Service name="CatalinaMES"> <Connector port="8085" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> <Engine name="CatalinaMES" defaultHost="localhost"> <Realm className=""> <Realm className="" resourceName="UserDatabase"/> </Realm> <Host name="localhost" appBase="webappsMES" unpackWARs="true" autoDeploy="true"> <Context path="/mes-manager-web" docBase="C:\Program Files\Tomcat 8.5\webappsMES\mes-manager-web" debug="0" privileged="true"></Context> <Valve className="" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" /> </Host> </Engine> </Service> <!-- deployerp --> <Service name="CatalinaERP"> <Connector port="8082" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> <Engine name="CatalinaERP" defaultHost="localhost"> <Realm className=""> <Realm className="" resourceName="UserDatabase"/> </Realm> <Host name="localhost" appBase="webappsERP" unpackWARs="true" autoDeploy="true"> <Context path="/erp-manager-web" docBase="C:\Program Files\Tomcat 8.5\webappsERP\erp-manager-web" debug="0" privileged="true"></Context> <Valve className="" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" /> </Host> </Engine> </Service> </Server>
Among them, a <service> node represents a service, that is, a deployed project.
The name attribute of the <service> node is changed to the name of the corresponding Catalina folder. The name attribute of the <Engine> node has also been changed to the name of the corresponding Catalina folder.
The port property of the <Connector> node is the port number of the project, just be careful not to conflict.
The appBase property of the <Host> node has been changed to the corresponding webapps folder.
The path attribute of the <Context> node is the address at the time of access, that is, the access address of the project isServer ip: value of project port number/path attribute
. According to the current configuration, the native access address of my MES project is127.0.0.1:8085/mes-manager-web
. The docBase property of the <Context> node is the local path of the project war package. Just modify it to the absolute path of the war package on the local machine.
5 Modifications and
Edit the installation directory\bin\ and add:
SET JAVA_HOME=C:\Program Files\Java\jre1.8.0_181 SET TOMCAT_HOME=C:\Program Files\Tomcat 8.5
The first is the installation location of JRE, and the second is the installation path of tomcat.
Add the same content in the same position.
6 Double-click to run tomcat
Note that a dos window will be opened at this time, and the project startup information will be printed like the IDEA console. When the project starts successfully, do not close the dos window, let it remain open. If tomcat is turned off, it will stop running.
7 Things to note
If multiple projects use the spring framework, an error may be reported when configuring a tomcat multi-port multi-application.
Workaround: Add the following nodes on each project:
<context-param> <param-name>webAppRootKey</param-name> <param-value></param-value> </context-param>
Ensure that the <param-name> of each project is different from the <param-value> corresponding to the webAppRootKey. For example, the first one uses webapp.root1, the second one uses webapp.root2, etc.
In addition, you should also pay attention to whether the server's firewall allows external access to the port you want to configure.
This is the article about the methods and steps of Tomcat deploying multiple war packages. For more related content on Tomcat deploying multiple war packages, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!