Multi-project deployment of Tomcat and Nginx, deployment of the same IP on different ports, complete tutorial

1.Background

Multiple projects, same IP, different port deployment access.

1.1 Requirements:

  1. Deploy a PC project, access address: http://192.168.31.1:8085/project name
  2. Deploy a dist project, access address: http://192.168.31.1:8086/project name
  3. Note: The above are just examples!

1.2 Personal experience

I have no such experience before, and I have not found any information on integration, so I will record it together~
Insert image description here

2.Tomcat

2.1 Download address

The lower version or the latest version is not recommended. The latest version may be unstable. Download address: link
Insert image description here

2.2 Modify webapps

This modification order is not fixed, but I am used to configuring and modifying it this way. You can do whatever you want. In order to distinguish it, I will copywebappsTwo numbers are added for distinction.

Insert image description here

2.2.1 webapps1&webapps2

webapps1
Insert image description here

webapps2
Insert image description here

2.2.2 Tomcat->conf configuration file

There is a conf configuration file in the Tomcat installation directory, open it. existconfIn the directory, there is acatalina.policyMake a copy of the configuration file and differentiate it yourself. I use 1 and 2 to differentiate. (You don’t need to open this file, just make a copy)
Insert image description here

2.2.3 serve.xml configuration file

Copy the service and modify it.This IP is the same~, just the port is different!
Insert image description here

2.2.4 Start Tomcat server

Tomcat installation directory–>bin–>startup.bat, or use the command to start in the command window.

Complete startup
Insert image description here

2.2.5 Access deployment: 8085

Access the address you configured in the browser address bar (expected result: access failed):http://xxx.xxx.xxx.xxx:8085/pc
Insert image description here

Access the address you configured in the browser address bar (expected result: access successful):http://xxx.xxx.xxx.xxx:8085/dist
Insert image description here

2.2.6 Access deployment: 8086

Access the address you configured in the browser address bar (expected result: access failed):http://xxx.xxx.xxx.xxx:8086/dist
Insert image description here

Access the address you configured in the browser address bar (expected result: access successful):http://xxx.xxx.xxx.xxx:8086/pc
Insert image description here

-------------------------------------------------- -----------------------Divider line-------------------------- -------------------------------------------------- --------------------------

3. Nginx

3.1 Download and decompress Nginx

Official website address: link
Try to download the stable version!

3.2 Unzip

Insert image description here

3.3 Copy html

Insert image description here

3.4 Put in the packaged project file

Project file in html:
Insert image description here
Project file in html2:
Insert image description here

3.5 Modify nginx.conf configuration

Installation directory–>conf–>nginx.conf
Insert image description here

3.6 Start Nginx

Startup: Use start nginx in the command window or use the exe in the installation directory to start the program. Since my command window does not show that the startup is successful, we check whether the startup is successful in the resource management, as follows:Started successfully
Insert image description here

Insert image description here

3.7 Access port 80

Under normal configuration, port 80 can only access: dist project
Access address: localhost:80/distAccess
Insert image description here
address: localhost:80/pcpc
Insert image description here

3.8 Access port 9090

Under normal configuration, port 9090 can only access: pcpc project
Access address: localhost:9090/pcpc

Insert image description here

Access address: localhost:9090/dist
Insert image description here

4. Summary

The configuration of Tomcat and Nginx with the same host address and different ports is complete. If there are any problems or better methods, please leave comments~~~~~~

Insert image description here

Guess you like

Origin blog.csdn.net/qq_24484317/article/details/129252263