1. Open the conf/server. xml file in the tomcat installation directory.
Find
</Engine>
</Service>
Add the following content (three methods are available for the moment ):
First:
<Host name = "www.haokan946.cn" DEBUG = "0" appbase = "webapps" unpackwars = "true" autodeploy = "true" xmlvalidation = "false" xmlnamespaceaware = "false">
<Context Path = "" docbase = "www" DEBUG = "0" reloadable = "true" crosscontext = "true"/>
<Logger classname = "org. Apache. Catalina. Logger. filelogger" directory = "logs" prefix = "www_5sai_log." suffix = ". txt"
Timestamp = "true"/>
</Host>
The above content is to create a WWW folder under the webapps directory of Tomcat as the Home Directory of www.haokan946.cn.
Second:
<Host name = "test.5sai.net.cn" DEBUG = "0" appbase = "C: // test/www" unpackwars = "true" autodeploy = "true">
<Context Path = "" docbase = "."/>
<Valve classname = "org. Apache. Catalina. Valves. accesslogvalve" directory = "logs" prefix = "test_5sai_access_log ."
Suffix = ". txt" pattern = "common" resolvehosts = "false"/>
<Logger classname = "org. Apache. Catalina. Logger. filelogger" directory = "logs" prefix = "test_5sai_log." suffix = ". txt" timestamp = "true"/>
</Host>
The above content means to create a WWW folder under the test folder on drive C as the Home Directory of the domain name test.5sai.net.cn
Third, if/var/WWW in Linux is used as the main directory of the domain name test.5sai.net.cn, the content is as follows:
<Host name = "test.5sai.net.cn" DEBUG = "0" appbase = "/var/www" unpackwars = "true" autodeploy = "true">
<Context Path = "" docbase = "."/>
<Valve classname = "org. Apache. Catalina. Valves. accesslogvalve" directory = "logs" prefix = "test_5sai_access_log ."
Suffix = ". txt" pattern = "common" resolvehosts = "false"/>
<Logger classname = "org. Apache. Catalina. Logger. filelogger" directory = "logs" prefix = "test_5sai_log." suffix = ". txt" timestamp = "true"/>
</Host>
Add another
<Host name = "www.haokan946.cn" DEBUG = "0" unpackwars = "true">
<Valve classname = "org. Apache. Catalina. Valves. accesslogvalve"
Directory = "/var/log/tomcat" prefix = "www_5sai_access_log." suffix = ". txt"
Pattern = "common"/>
<Logger classname = "org. Apache. Catalina. Logger. filelogger"
Directory = "/var/log/tomcat" prefix = "www_5sai_log." suffix = ". txt"
Timestamp = "true"/>
<Context Path = "" docbase = "/var/www" DEBUG = "0" reloadable = "true"/>
</Host>
The main directory of the domain name www.haokan946.cn is/var/www. All access logs of the site are stored in/AR/log/tomcat.
Test:
For Windows users, open the hosts file C:/Windows/system32/Drivers/etc,
Linux users can open the/ECT hosts file or VI/ECT/hosts file.
The modified content is as follows:
127.0.0.1 localhost
127.0.0.1 www.haokan946.cn
127.0.0.1 test.5sai.net.cn
Open your browser and enter the URL for testing!