1. After Tomcat is installed, a server is provided. The default port configuration is 8080. The corresponding directory is .. \ Tomcat 6.0 \ webapps.
2. Configure multiple ports in Tomcat 6.0, that is, add several servers to Tomcat and set the corresponding directory. The following uses adding two port numbers as an example.
Step 1: Modify server. xml [.. \ Tomcat 6.0 \ conf]
(1) Tomcat provides the following:
XML Code
-
- <Service name = "Catalina">
-
-
- <Connector Port = "8090" maxhttpheadersize = "8192"
-
- Maxthreads = "150" minsparethreads = "25" maxsparethreads = "75"
- Enablelookups = "false" redirectport = "8443" acceptcount = "100"
-
- Connectiontimeout = "20000" disableuploadtimeout = "true"/>
-
-
- <Connection Port = "8009"
-
- Enablelookups = "false" redirectport = "8443" protocol = "AJP/1.3"/>
-
-
-
- <Engine name = "Catalina" defaulthost = "localhost">
-
-
- <Realm classname = "org. Apache. Catalina. realm. userdatabaserealm"
-
- Resourcename = "userdatabase"/>
-
-
- <Host name = "localhost" appbase = "webapps"
-
- Unpackwars = "true" autodeploy = "true"
-
- Xmlvalidation = "false" xmlnamespaceaware = "false">
-
- </Host>
-
-
- </Engine>
-
-
-
- </Service>
(2) Add two port numbers, namely service name, engine name, And appbase,
Of course, do not forget to modify the port number to avoid duplication.
XML Code
-
- <Service name = "catalina1">
-
-
- <Connector Port = "8091" maxhttpheadersize = "8192"
-
- Maxthreads = "150" minsparethreads = "25" maxsparethreads = "75"
-
- Enablelookups = "false" redirectport = "8443" acceptcount = "100"
- Connectiontimeout = "20000" disableuploadtimeout = "true"/>
-
-
- <Connection Port = "8009"
-
- Enablelookups = "false" redirectport = "8443" protocol = "AJP/1.3"/>
-
-
-
- <Engine name = "catalina1" defaulthost = "localhost">
-
-
-
- <Realm classname = "org. Apache. Catalina. realm. userdatabaserealm"
- Resourcename = "userdatabase"/>
-
-
- <Host name = "localhost" appbase = "websockets 1"
-
- Unpackwars = "true" autodeploy = "true"
-
- Xmlvalidation = "false" xmlnamespaceaware = "false">
-
- </Host>
-
-
-
- </Engine>
-
-
- </Service>
XML Code
-
- <Service name = "catalina2">
-
-
- <Connector Port = "8092" maxhttpheadersize = "8192"
-
- Maxthreads = "150" minsparethreads = "25" maxsparethreads = "75"
-
- Enablelookups = "false" redirectport = "8443" acceptcount = "100"
-
- Connectiontimeout = "20000" disableuploadtimeout = "true"/>
-
- <Connection Port = "8009"
-
- Enablelookups = "false" redirectport = "8443" protocol = "AJP/1.3"/>
-
-
-
- <Engine name = "catalina2" defaulthost = "localhost">
-
-
-
- <Realm classname = "org. Apache. Catalina. realm. userdatabaserealm"
-
- Resourcename = "userdatabase"/>
-
- <Host name = "localhost" appbase = "webbench 2" <! -- This place is very important. I didn't modify it today. As a result, several applications under webapps can access it through multiple ports, so I had to copy the applications under the default webapps to other places, create catalina2/localhost/under $ {tomcat_home}/CONF/, and create different XML files to direct docbase to the Application Path -->
-
- Unpackwars = "true" autodeploy = "true"
-
- Xmlvalidation = "false" xmlnamespaceaware = "false">
-
- </Host>
-
-
-
- </Engine>
-
-
-
- </Service>
Step 2: Create a deployment directory
.. \ Tomcat 6.0 \ web1_1
.. \ Tomcat 6.0 \ web1_2
You can also copy the useful Tomcat 6.0 \ webapps files to the new deployment directory.
Step 3: Create the configuration file directory and configuration file
.. \ Tomcat 6.0 \ conf \ catalina1 \ localhost
.. \ Tomcat 6.0 \ conf \ catalina2 \ localhost
Host-manager.xml
Manager. xml
For configuration of the configuration file, see under .. \ Tomcat 6.0 \ conf \ Catalina \ localhost. You only need to modify the corresponding directory.
The general configuration steps are as follows. Now we can place different war packages in different locations for access.
The above configuration method is also suitable for Tomcat 5.5
[Switch] configure multiple ports in Tomcat