Tomcat virtual host configuration, tomcat Virtual Host

Source: Internet
Author: User

Tomcat virtual host configuration, tomcat Virtual Host

For example, configure a VM named

1. Modify the HOST file in the window system [C: \ WINDOWS \ system32 \ drivers \ etc \ hosts]

2. Modify tomcat/conf/server. xml
<Host name = "" appBase = "d: \ sina">
<Context path = "/mail" docBase = "d: \ sina \ mail"/>
<Context path = "/news" docBase = "d: \ sina \ news"/>
Name: Host name of the virtual website
AppBase: Home Directory of the website
Path: virtual directory (for external access) (starts)
DocBase: Web application directory

3 Start the browser, in the address bar input: 8080/news/news.html press ENTER


(1) Every time you modify the server. xml file, you need to restart tomacat.
(2) If path = "" is null, It is the default web application, that is, the input
Http:// 8080/news.html press ENTER
(3) If you set the following code in the mail/WEB-INF/web. xml file:
<Welcome-file> mail.html </welcome-file>
That is, set the default open web page, that is, the URL entered in the browser is: 8080
(4) If you change the port attribute of the ctor tag in the server. xml file to 80, the default port number, you can enter: in the browser only

(5) A web server can have N web sites. Each web site has one <Host> element.

(6) If it is set to, it is really impossible to browse Sina website, so it is best to change to another virtual website.

(7) common attributes of Context:

Tomcat configuration problems in the VM

Configuration in the VM requires JDK, tomcat, corresponding database, and port configuration. For example, whether port 80 on the server is occupied.

How does one configure Tomcat-usersxml as the tomcat VM Configuration Manager?

In your hostA, the manager's web. xml

<! -- Define a Security Constraint on this Application -->
<Web-resource-name> Entire Application </web-resource-name>
<Url-pattern>/manager/* </url-pattern>
<Role-name> your-role </role-name>

<! -- Define the Login Configuration for this Application -->
<Auth-method> BASIC </auth-method>
<Realm-name> Application </realm-name>

<! -- Security roles referenced by this web application -->
The role that is required to log in to the Manager Application
<Role-name> your-role </role-name>

Replace your-role with the user defined by your tomcat-users.xml...

Related Article

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: 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.