tomcat single-machine multi-instance deployment

 In the process of development, because there are multiple web projects deployed and debugged, it is possible to configure too many instances to start by simply modifying the port number.

Proceed as follows:

1. Download a free version of ``tomcat7``.

2. Create a tomcat-ins folder in the tomcat directory as the root directory of multiple instances.

3. Create your own tomcat directory folder (conf/webapps) for each instance. Logs, work, and temp will be created automatically when the web program is started, so there is no need to manually create them.

4. Enter the downloaded tomcat7 directory and copy the files in the conf folder to the conf file in each instance directory.

5. Modify the port number (Server port, Connector port, AJP port) of server.xml in this conf folder.

6. Finally start these instances through a startup script. The specific steps are as follows:

The first four items in the above steps are all nonsense, and it should be clear at a glance through a diagram.

In the above figure, the apache tomcat7 directory on the left is the default directory after decompression, and other useless folders have been deleted.

The tomcat-ins directory is the root directory of multiple instances, and the rest is to create a corresponding directory for each web instance. Then copy the configuration information in the conf file. Modify the relevant port number.

Finally write a bat batch file to test the startup instance. The bat file location is shown in the figure above

code show as below:

@echo off
set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_45
set PATH=%JAVA_HOME%\bin;%PATH%
set CATALINA_BASE=%CD%
cd ../../apache-tomcat-7-8082/bin
catalina.bat start

The two variables CATALINA_HOME and CATALINA_BASE that need to be explained here, where CATALINA_HOME specifies the tomcat home directory, and CATALINA_BASE specifies the ins directory, because CATALINA_BASE is the same as the home directory by default. %CD% represents the disk letter and current directory.

Then by starting this bat file, if nothing else happens, our web instance is successfully started, and then other instances are started separately without any problems.

<end>

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326685153&siteId=291194637