Tomcat virtual host configuration scheme (domain name resolution) for Windows/Linux (Full Version)

Source: Internet
Author: User

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!

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.