Tomcat learning note _ host name-based VM Configuration

Source: Internet
Author: User
1. First, configure the network environment:

1. When a browser accesses a host name-based Vm, the access URL must use the host name, and the IP address cannot be used.
2. The ing between host names and IP addresses must be established throughout the network system.
2.1 use the local hosts file to establish the ing between the host name and IP address (c: \ windows \ system32 \ drivers \ etc \ hosts)
127.0.0.1 www.test.cn
127.0.0.1 www.test.com

After setting the hosts file, Ping localhost, www.test.cn, and www.test.com through the command line.


2.2 Use DNS (for money)

2. Configure Tomcat

Configuration Principle:

1. A <connector> element is used to configure an external connector. An independent <context> element must be configured for each listening port number of the Web server.

2. A connector corresponding to the <connector> element must have a <engine> element association

3. Associate one or more <context> elements with <engine> elements by embedding <context> elements and <engine> elements in the same <service> element

Configuration method:

Add another <service> element to the <Server> element of the server. xml file.

<Service name="secend-serv">     <Connector port="80" protocol="HTTP/1.1"  connectionTimeout="20000"  redirectPort="8443" />                       <Engine name="Catalina" defaultHost="www.test.com">                    <Host name="www.test.com"  appBase="D:\webSite1"  unpackWARs="true" autoDeploy="true" />                <Host name="www.test.cn"  appBase="D:\webSite2"  unpackWARs="true" autoDeploy="true" />                  </Engine>           </Service>  


Note:

1. The name of the <service> element must be different from that of the original <service> element. Therefore, change it to: secend-Serv.

2. Modify the port attribute of the <connector> element to 80 (or another port that you want not to use)

3. Modify the defaulthost attribute of the <engine> element to the name attribute value of the

4. The name attribute of the

You can access www.test.com/project name in the browser through the above two steps to access your project

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.