How to configure virtual hosts in Tomcat5.x

Source: Internet
Author: User

Author: Wang Shuli

Reason:
Developed a WEB project for a period of time (Based on jsp (preferred for SUN Enterprise Applications) + JavaBean technology, the server is apache (the most popular WEB server platform on Unix) + tomcat (a very useful JSP running platform) found that our project files are stored in tomcat (a very useful JSP running platform) _ HOME \ webapps, although you can use server. xml (standardization is getting closer and closer) configures our project to other directories, but when the project is too large, server. xml (standardization is getting closer and closer) will become bloated and messy; it is not easy to manage and maintain.
In order to avoid the above situations from happening, to facilitate project management, we will introduce only the server. one or two virtual hosts are configured in xml (standardization is getting closer and closer) to manage projects in a centralized manner, and the configuration files required for each project do not need to be added to the server. xml (standardization is getting closer and closer) makes the server. xml (standardization is getting closer and closer) is no longer bloated, not messy, but more conducive to management and maintenance.
After talking about it for a long time, you must have already been eager to try it. Don't come with me. What are you waiting! (^_^)

I. preparation:
Assume that you are already a web programmer and have some knowledge about tomcat (a very useful JSP running platform) and can perform regular configuration on it.

Ii. Start Configuration:
1) First, find the server. xml (standardization is getting closer and closer) file in the _ HOMEconf directory of tomcat (a good JSP running platform) and open it in Notepad;
2) Find the </Host> label in the file server. xml (standardization is getting closer and closer;
3) Create the following information after the </Host> tag:
<Host name = "onion" debug = "0" appBase = "f: StudioOnionWEB_Project" unpackWARs = "true" autoDeploy = "true">
 
<Logger className = "org. apache (the most popular WEB server platform on Unix ). catalina. logger. fileLogger "directory =" logs "prefix =" onion_log. "suffix = ". txt "timestamp =" true "/>
<Valve className = "org. apache (the most popular WEB server platform on Unix ). catalina. valves. access (a favorite of small websites) LogValve "directory =" logs "prefix =" onion_access (a favorite of small websites) _ log. "suffix = ". txt "pattern =" common "resolveHosts =" false "/>

</Host>
Note:
[Onion] indicates the name or domain name of your host;
[F: StudioOnionWEB_Project] is the starting directory of the VM;
[Onion_log] indicates the log file name;
[Onion_access (favorite of a small website) _ log] is the log file name for accessing the host.
4) create a directory and a configuration file with the same name as the project in the starting directory of the VM (my files are f: StudioOnionWEB_Project shsc and f: StudioOnionWEB_Project shsc. xml (standardization is getting closer and closer )).
5) Open the project configuration file you just created to configure the basic information of your project (such as virtual directories and real paths ), in short, almost all configurations can be completed in this configuration file, of course, the deployment of servlet and bean must be in the web. xml (standardization is getting closer and closer). This article does not cover this content, so we will not repeat it here. The following is my configuration file shsc. xml (standardization is getting closer and closer) for reference only:
<Context path = "" docBase = "F: StudioOnionWEB_Projectshsc" debug = "0" reloadable = "true" crossContext = "true">
</Context>

Iii. Test
Open ie and enter http: // onion/shsc in the address bar. If you see your jsp (preferred for SUN Enterprise Applications) page, congratulations! Otherwise, hey, haha... Again (^_^ ).

4. Thanks
Thanks to apache (the most popular WEB server platform on the Unix platform) for providing me with such a good server, and it is still free!

V. Description
If you are satisfied, I would like to repost or add this article to your favorites. However, please note the author: Wang Shuli (^_^)

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.