Tomcat virtual host configuration, tomcat Virtual Host
For example, configure a VM named www.sina.com.
1. Modify the HOST file in the window system [C: \ WINDOWS \ system32 \ drivers \ etc \ hosts]
127.0.0.1 www.sina.com
2. Modify tomcat/conf/server. xml
<Host name = "www.sina.com" appBase = "d: \ sina">
<Context path = "/mail" docBase = "d: \ sina \ mail"/>
<Context path = "/news" docBase = "d: \ sina \ news"/>
</Host>
Name: Host name of the virtual website
AppBase: Home Directory of the website
Path: virtual directory (for external access) (starts)
DocBase: Web application directory
Note:
3 Start the browser, in the address bar input: http://www.sina.com: 8080/news/news.html press ENTER
Note:
(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://www.sina.com: 8080/news.html press ENTER
(3) If you set the following code in the mail/WEB-INF/web. xml file:
<Welcome-file-list>
<Welcome-file> mail.html </welcome-file>
</Welcome-file-list>
That is, set the default open web page, that is, the URL entered in the browser is: http://www.sina.com: 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: http://www.sina.com 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 www.sina.com, 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 -->
<Security-constraint>
<Web-resource-collection>
<Web-resource-name> Entire Application </web-resource-name>
<Url-pattern>/manager/* </url-pattern>
</Web-resource-collection>
<Auth-constraint>
<Role-name> your-role </role-name>
</Auth-constraint>
</Security-constraint>
<! -- Define the Login Configuration for this Application -->
<Login-config>
<Auth-method> BASIC </auth-method>
<Realm-name> Application </realm-name>
</Login-config>
<! -- Security roles referenced by this web application -->
<Security-role>
<Description>
The role that is required to log in to the Manager Application
</Description>
<Role-name> your-role </role-name>
</Security-role>
Replace your-role with the user defined by your tomcat-users.xml...