Tomcat configures multiple service, multiple apps with the same name running under one tomcat

Source: Internet
Author: User
Tags bind root directory tomcat

Tomcat uses the default installation, in order to Tamcat directly bind multiple domain names, here we need to modify the configuration file: C:\Program files\apache software Foundation\tomcat 5.5\conf\server.xml

Server.xml is modified in the following ways:

(i) Multi-domain binding

1. If you want to bind the Web site, first of all is to change the Tomcat's default access port 8080 to 80

Original:
<connector port= "8080" maxhttpheadersize= "8192" maxthreads= "minsparethreads=" "maxsparethreads=" "enablelookups="false"redirectport="8443"Acceptcount = "connectiontimeout=" "20000" disableuploadtimeout= "true"/>

After modification:
<connector port= "maxhttpheadersize=" 8192 "maxthreads=" "minsparethreads=" maxsparethreads= "75" Enablelookups= "false" redirectport= "8443" acceptcount= "" connectiontimeout= "20000" disableuploadtimeout= "true"/ >

In fact, this is the port:8080, modified to port:80 on it, the other parameters unchanged

2. Next is the focus of haha ...
Original:
<engine name= "Catalina" defaulthost= "localhost" >
</Engine>
Of course, I've removed all the comment codes here, and the province is an eyesore.


After modification:
<engine name= "Catalina"Defaulthost=WWW.ABC. com>

Abcapps"Unpackwars="true"Autodeploy="true"Xmlvalidation="false"Xmlnamespaceaware="false"

www.cba.comappbase== "D:\CBA"Unpackwars="true"Autodeploy="true"Xmlvalidation="false"Xmlnamespaceaware="false"/>

</Engine>

Here to explain the configuration above
Engine Dafaulthost: Indicates access to the Tomcat by default into the host, note must not be localhost, or others through your IP access, will default into the Tomcat management interface.

Host Name: Represents the domain name that the host is bound to, and if bound localhost can access the host by entering localhost in the browser.

Host AppBase: Represents the file storage path that the host binds to, either using a relative path or an absolute path.

Follow the configuration above:
1. If I enter http://localhost in the browser, then visit C:\Program files\apache software foundation\tomcat 5.5\webapps\root website
2. If you enter http://www.abc.com, visit the website under C:\Program files\apache software Foundation\tomcat 5.5\abcapps\root
3. If you enter http://www.cba.com, visit the website under D:\cba\ROOT.

Note that there is a root directory that needs to be created, and we simply place the site in the appropriate root directory to access it through the corresponding domain name.

There are many parameters in this, I am not very clear, but this can be done to achieve multi-domain binding haha. and the Site page modified as long as the direct overlay can be, Tomcat can automatically update the class and page, of course, if you modify the Web. xml or LIB, you need to restart Tomcat.

(ii) virtual directory

Unpackwars= "true" autodeploy= "true"
Xmlvalidation= "false" Xmlnamespaceaware= "false" >
<context path= "/cqq" docbase= "F:\java\cqqapp" debug= "0" reloadable= "true" crosscontext= "true" >
</Host>


Where the host tag is used to configure the virtual host, that is, multiple domain names can point to a tomcat, the format as long as the reference to the default

OK.

<context> is the child element of the host tag, which represents a virtual directory, which has two properties, and path is the virtual directory name.

The docbase is the specific file location. Here my virtual path name is CQQ, in fact my program is HTML, JSP,

The servlet is placed under the F:\java\cqqapp directory.

So I can access my virtual directory through http://127.0.0.1/cqq/.

Another approach is to:

Configure two sites
<context path= "" docbase= "D:/tomcat5.5/portal" debug= "0" reloadable= "true"/>
</Host>

Unpackwars= "true" autodeploy= "true"
Xmlvalidation= "false" Xmlnamespaceaware= "false" >
<context path= "" docbase= "D:\Tomcat5.5\abc" debug= "0" reloadable= "true"/>
</Host>

After this setting, the input domain name can be divided into two sites

However, because the default site is not specified, it cannot be accessed when the IP is entered directly.

So add D:\Tomcat5.5\conf\Catalina\localhost\ROOT.xml.
Content such as
<context path= "/" docbase= "${catalina.home}/portal" debug= "5" reloadable= "true" crosscontext= "true" >
</Context>

This can be implemented to enter the domain name to a site, enter the IP on the default to d:/tomcat5.5/portal this site

But, however, the problem arose.

These two sites start to consume quite a memory, Tomcat memory settings I have set to 1400M (again high TOMCAT5 cannot boot), so can not start three applications at the same time.


Do you have a way to start an application and bind multiple domain names?
The following (so that Tomcat is definitely not bootable, just to express my meaning)

Unpackwars= "true" autodeploy= "true"
Xmlvalidation= "false" Xmlnamespaceaware= "false" >
<context path= "" docbase= "D:\Tomcat5.5\abc" debug= "0" reloadable= "true"/>
</Host>

Because I am integrated, so I don't have to change the port 8080 Oh ~~~~~

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.