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: \ testwww" 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 of C: WINDOWSsystem32driversetc,
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
This article from the CSDN blog, reprinted please indicate the source: aspx "> http://blog.csdn.net/forever_bin/archive/2009/04/27/4131005.aspx