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