3.1 configure Virtual Hosts
A website is configured as a virtual host.
To configure a virtual host (website) on the Tomcat server, you must modify the server in the conf folder. the xml configuration file uses the host element for configuration to open the server. XML, you can see that the Tomcat server comes with a virtual host (website) named localhost, as shown in:
Put the developed Java Web application in the webapps folder, and then you can access it using "http: // localhost: Port Number/javawebappname,
The access is the virtual host whose name is "localhost". This virtual host manages all web applications in the webapps folder.
You can configure a virtual host as follows:
<Host name="www.dujiechn.cn" appBase="F:\JavaWeb"> </Host>
Here we configure a new virtual host,
The VM name is "www.dujiechn.com", and the VM "www.dujiechn.com" manages all web applications in the javawebapps folder.
When we use the domain name "www.baidu.com" on the Internet to access Baidu's website, we actually access a VM named "www.baidu.com, so when we want to access this virtual host named "www.dujiechn.com", we can use "Domain Name (www.dujiechn.com)" to access
Note: appbase = "F: \ javawebapps". The javawebapps folder here represents not the root directory of a project, but a folder that stores one or more javaweb applications, as shown in:
Domain name registration in Windows
To access the configured host (website) externally through the domain name, you must register the domain name used to access the website on the DNS server or Windows system and find"C: \ windows \ system32 \ drivers \ etc"Hosts file under the directory, bind the domain name and IP address of the newly added website together, in this way, we can use the domain name www.dujiechn.com in the browser to access the Web applications managed in the virtual host www.dujiechn.com.
Open the Tomcat server and enter the domain name in the address bar.
Tomcat Virtual Host Configuration