Configure a VM on Tomcat

Source: Internet
Author: User
Configure a VM on Tomcat Keywords:Configure a VM on Tomcat

What is a virtual host? Virtual Hosts use special hardware and software technologies to divide a Computer Host into a "virtual" host, each virtual host has an independent domain name and IP address (or shared IP address) with a complete Internet server (WWW, FTP, email, etc.) function. Using the "virtual host" technology, each virtual host is exactly the same as an independent host. Each virtual host has an independent domain name and has a complete Internet server function.

Tomcat supports the virtual host technology. It does not require additional plug-ins and is easy to configure.

Preparations
We will configure two virtual hosts, assuming the domain names are
Www.sentom1.net
Www.sentom2.net
For test convenience, please go to the client's:
Win2k: // winnt/system32/Drivers/etc/hosts
Linux:/etc/hosts
Add the following content to the file, and then check whether the two domain names are correctly resolved.

192.168.0.1 www.sentom1.net
192.168.0.1 www.sentom2.net

Of course, this does not work in the production environment. You need to perform corresponding domain name resolution on the DNS.

2. tomcat installation
Tomcat installation is not covered in this article. Please refer to here. Make sure that Tomcat is correctly installed. Otherwise, do not proceed with the following configuration steps.

Copy the webapps directory under the Tomcat directory in the same directory. The directory name is divided into webapps 2, and then the webapps directory is renamed to webapps 1. The directory structure of Tomcat is roughly as follows:

Tomcat
| -- Bin
| -- Common
| -- Conf
| -- Logs
| -- Server
| -- Shared
......
| -- Webpapps1
| -- Webpapps2
| -- Work

Finally, write a simple HTML file for testing. The file name is test.html. The file content is as follows:

 

You are visiting www.sentom1.net

 

 

Place the test.html file in the tomcat/website1/root and tomcat/website2/root directories respectively, change "www.sentom1.net" in the tomcat/webbench 2/root/test.html file to "www.sentom2.net ".

At this point, the preparations for the early stage have been completed, all of which are physical work.

3. configure a VM
Independent IP addresses and shared IP addresses are mentioned above. This article describes the shared IP mode, in which all virtual hosts use the same IP address. Currently, this mode is used for virtual hosts provided by IDC in China. The advantage of this mode is that it saves a limited number of IP addresses. The disadvantage is that the virtual master machine can only access through the domain name but not through the IP address (in fact, it is not a disadvantage, it only has a slight impact on the access mode of users in the email system ). Another independent IP Mode is mainly used in the mail service, so we will not introduce it here.

Configure www.sentom1.net VM

Open the tomcat/CONF/server. xml file, delete all content between the host elements, and add the following content to the original location of the host element.

Unpackwars = "true" autodeploy = "true">


Directory = "logs" prefix = "sentom1_access_log." suffix = ". txt"
Pattern = "common" resolvehosts = "false"/>


Directory = "logs" prefix = "sentomw.log." suffix = ". txt"
Timestamp = "true"/>

Configure www.sentom2.net VM

Append the following content to the end of the host element. Pay attention to the changes in the value of the name attribute and appbase attribute in the host element.

Unpackwars = "true" autodeploy = "true">


Directory = "logs" prefix = "sentom2_access_log." suffix = ". txt"
Pattern = "common" resolvehosts = "false"/>


Directory = "logs" prefix = "sentom2_log." suffix = ". txt"
Timestamp = "true"/>

Now you can start Tomcat and access
Http://www.sentom1.net: 8080/test.html
Http://www.sentom2.net: 8080/test.html
If the accessed page contains the following content, it indicates that the VM has been configured successfully. Otherwise, check your configuration process and configure it again according to the document.
 
You are visiting www.sentom1.net

You are visiting www.sentom2.net

 

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.