To explain the method of how Tomcat server binds multiple domain names and virtual directories _tomcat

Source: Internet
Author: User
Tags tomcat server

Tomcat with the default installation, 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
The Server.xml is modified as follows:
(i) Multi-domain binding
1. If you want to bind the site, first of all is to put Tomcat's default access port 8080, modified to 80
Original:

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

After modification:

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

In fact, here is the port:8080, modified into port:80 on it, the other parameters are unchanged
2. The next point is the emphasis haha ...
Original:

<engine name= "Catalina" defaulthost= "localhost" >  
 

Of course, here I removed the annotation code, the province of the unsightly

After modification:

<engine name= "Catalina" defaulthost=[url]www.abc[/url].com>

 
 

Here to explain the configuration above
Engine's dafaulthost: To access this tomcat default to enter the host, note must not be localhost, or other people through your IP access, will default into Tomcat's management interface.
Host's name: Represents the domain name that the host binds to, or if the binding localhost can access the host by entering localhost in the browser.
Host AppBase: Represents the file-holding path for this host binding, which can use a relative or absolute path.
Follow the above configuration:
1. If I enter [Url]http://localhost[/url] in the browser, I access C:\Program files\apache Software foundation\tomcat 5.5\ Webapps\root Web site
2. If you enter [Url]http://www.abc.com[/url] then access C:\Program files\apache Software foundation\tomcat 5.5\ Abcapps\root Web site
3. If you enter [Url]http://www.cba.com[/url], you can access the Web site under D:\cba\ROOT.
Note that there is a root directory that needs to be created, We simply put the site to the corresponding root directory to the following, you can access through the corresponding domain name.
There are a lot of parameters in this, I am not very clear, but this does make it possible to do multiple domain binding haha. and the Site page modified as long as the direct coverage can be, Tomcat can automatically update the class and page, of course, if modified Web.xml or LIB, You will need to restart Tomcat.
(ii) virtual directory

 
 

Where the host tag is used to configure a virtual host, that is, multiple domain names can point to a tomcat, and the format simply references the default

OK.

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

And 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 [Url]http://127.0.0.1/cqq/[/url].
Another method is:
Configure two sites

 
 

After this setting, the input domain name can be divided into two sites
However, because the default site is not specified, you cannot access the IP directly when you enter it.
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 of the site, input IP on the default to d:/tomcat5.5/portal this site
But, however, the problem arose.
These two sites boot quite memory, Tomcat memory settings I have set to 1400M (again high TOMCAT5 cannot start), so can not start three applications at the same time.

We have not implemented, to open an application and binding multiple domain names method.
As follows (this will definitely not start Tomcat, just to express my meaning)

 
 

Because I am integrated, so there is no need to change the 8080 port. 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.