Configure web virtual ing for Tomcat and configure Virtual Hosts

Source: Internet
Author: User
Configure web virtual ing for Tomcat and configure Virtual Hosts

 

There are three methods to configure the WEB virtual ing directory:

 

First (to restart the server ):

Open the server. xml file under Tomcat 6.0 \ conf,

Add a statement in the preceding line of (Test.html) is a file stored in the E: \ code \ news directory. If it is changed to Path = "/Hello", access http: // localhost in the browser: 8000/Hello/test.html.


Note:For examplePath = "/hello"
Note that there must be a backslash '/'

 Reloadable = "true" after modifying the source program, save it and automatically restart the server. However, if you modify the JSP file, you do not need to restart the server.

Second (no need to restart the server ):

Create an XML file in the directory \ Tomcat 6.0 \ conf \ Catalina \ localhost (for example

A. XML) file content: <context docbase = "this point points to the directory you want to map, such as (E: \ code \ news

) "/> Access http: // localhost: 8000/A/test.html in the browser.
Note: test.html is a file stored in the E: \ code \ news directory;
If the Catalina folder cannot be found in the conf folder, copy the Catalina folder under \ Tomcat 6.0 \ work to the \ Tomcat 6.0 \ conf file.

 

 

 

 

Third (it is also the easiest to directly drop the directory folder to the webapps directory without restarting the server ):

Method 1. Directly drop the directory folder into the webapps directory


Method 2. it is convenient to package folders into war files in the webapps directory. It is also common to send files to customers in this way. You can package folders into war files: first, open the folder path you want to package in the doc Environment
For example, pay attention to the last point ".".

 

 

 

 

Configure the VM:


Suppose you want to configure a virtual host on your computer, for example, www.google.com;

Enter www.google.com in a browser to access the resources on your local server,

The procedure is as follows:

Suppose you create a Google folder on the drive with a new1 folder, The new1 folder contains an a.html file and a WEB-INF folder, and the WEB-INF folder contains a web.xmlfile (this file uses a.html as the home page ),

The content in the web. xml file is:

[HTML]
View plaincopy
  1. <? XML version = "1.0" encoding = "ISO-8859-1"?>
  2. <Web-app xmlns = "http://java.sun.com/xml/ns/javaee"
  3. Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
  4. Xsi: schemalocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  5. Version = "2.5">
  6. <Welcome-file-List>
  7. <Welcome-File> a.html </welcome-File>
  8. </Welcome-file-List>
  9. </Web-app>

In fact, this file is the beginning and end of the web. xml file under the Tomcat 6.0 \ conf directory.

 


Then, in the Tomcat 6.0 \ conf directory, the server. add such a program to the XML file. Put this statement on the </engine>. Remember to add the program to the server. in the XML file, replace port 8080 with 80:

[HTML]
View plaincopy
  1. <Host name = "www.google.com" appbase = "E: \ google">
  2. <Context Path = "" docbase = "E: \ google \ news1"/>
  3. </Host>

Then add the Host IP address and
Www.google.com

The hosts file is in the c: \ windows \ system32 \ drivers \ etc directory. The host IP address is usually displayed when you open the hosts file, for example, 127.0.0.1 www.google.com.

 

Finally, access www.google.com in a browser to view the contents of the.html file. (Restart the server)

 

 

 

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.