[Switch] configure multiple ports in Tomcat

Source: Internet
Author: User

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
  1. <Service name = "Catalina">
  2. <Connector Port = "8090" maxhttpheadersize = "8192"
  3. Maxthreads = "150" minsparethreads = "25" maxsparethreads = "75"
  4. Enablelookups = "false" redirectport = "8443" acceptcount = "100"
  5. Connectiontimeout = "20000" disableuploadtimeout = "true"/>
  6. <Connection Port = "8009"
  7. Enablelookups = "false" redirectport = "8443" protocol = "AJP/1.3"/>
  8. <Engine name = "Catalina" defaulthost = "localhost">
  9. <Realm classname = "org. Apache. Catalina. realm. userdatabaserealm"
  10. Resourcename = "userdatabase"/>
  11. <Host name = "localhost" appbase = "webapps"
  12. Unpackwars = "true" autodeploy = "true"
  13. Xmlvalidation = "false" xmlnamespaceaware = "false">
  14. </Host>
  15. </Engine>
  16. </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
  1. <Service name = "catalina1">
  2. <Connector Port = "8091" maxhttpheadersize = "8192"
  3. Maxthreads = "150" minsparethreads = "25" maxsparethreads = "75"
  4. Enablelookups = "false" redirectport = "8443" acceptcount = "100"
  5. Connectiontimeout = "20000" disableuploadtimeout = "true"/>
  6. <Connection Port = "8009"
  7. Enablelookups = "false" redirectport = "8443" protocol = "AJP/1.3"/>
  8. <Engine name = "catalina1" defaulthost = "localhost">
  9. <Realm classname = "org. Apache. Catalina. realm. userdatabaserealm"
  10. Resourcename = "userdatabase"/>
  11. <Host name = "localhost" appbase = "websockets 1"
  12. Unpackwars = "true" autodeploy = "true"
  13. Xmlvalidation = "false" xmlnamespaceaware = "false">
  14. </Host>
  15. </Engine>
  16. </Service>

 

XML Code
  1. <Service name = "catalina2">
  2. <Connector Port = "8092" maxhttpheadersize = "8192"
  3. Maxthreads = "150" minsparethreads = "25" maxsparethreads = "75"
  4. Enablelookups = "false" redirectport = "8443" acceptcount = "100"
  5. Connectiontimeout = "20000" disableuploadtimeout = "true"/>
  6. <Connection Port = "8009"
  7. Enablelookups = "false" redirectport = "8443" protocol = "AJP/1.3"/>
  8. <Engine name = "catalina2" defaulthost = "localhost">
  9. <Realm classname = "org. Apache. Catalina. realm. userdatabaserealm"
  10. Resourcename = "userdatabase"/>
  11. <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 -->
  12. Unpackwars = "true" autodeploy = "true"
  13. Xmlvalidation = "false" xmlnamespaceaware = "false">
  14. </Host>
  15. </Engine>
  16. </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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.