Tomcat to build multiple sites with different IP ports

Source: Internet
Author: User

Environment: Tomcat7.0.55
Tomcat to build multiple sites with different IP ports

Tomcat is used in the development environment, but sometimes also in production environments. In a production environment, you will encounter multiple sites that need to be placed under one tomcat. Sometimes it is also necessary to open multiple different ports at the same time to accept multiple domain name requests. Typically this situation opens multiple Tomcat instances. This approach has the following pros and cons:

Advantages: 1. Each site is independent from each other and is not disturbed by each other. No other sites will be affected because one site is busy. 2. You can do a high level of customization for Tomcat. When you need to do something that is unsafe for the container. You can use this condition to ensure that other sites are not affected. For example, you need to turn on custom threads.

Cons: 1. Waste of system resources, although Tomcat occupies little system resources, but too many instances of waste is very serious. Because Tomcat has a memory overflow problem, you need to change the memory, which leads to a lot of waste of system resources. 2. Management inconvenient, whether it is tuning, or the daily start, shutdown, port management. Although many commands in Linux are convenient, they are still very troublesome.

This paragraph is reproduced in http://java-boy.iteye.com/blog/588290, only reference it above the text Description section, the following operation is my personal reality to do the operation

Before you modify the configuration file, be careful to back up one copy!
Open configuration file Server.xml
At the end, add a service with the following code:

<Service name="Catalina2">     <Connector Port="8082" protocol="http/1.1"  ConnectionTimeout="20000"redirectport="8443" />                                     <Engine name="Catalina2" defaulthost="localhost" >       <Realm className="Org.apache.catalina.realm.UserDatabaseRealm"  ResourceName="Userdatabase"/>                     <Host name="localhost"appBase="Webapps_two"  Unpackwars="true " autodeploy="true"xmlvalidation="false"  Xmlnamespaceaware="false">                                   </Host>     </Engine>   </Service>

The above code can be implemented to create a new service Ctalina2, the port is 8082,appbase is

Webapps_two inside the picture, you have to create a new
Then restart the Tomcat service to access the http://localhost:8082 site
If access fails, there may be a reason for the firewall
Add a rule to access the 8082 port in the firewall advanced settings-inbound rules-new rule

Tomcat to build multiple sites with different IP ports

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.