The configuration summary of Tomcat master directory and virtual directory

Source: Internet
Author: User
Tags root directory tomcat

The following summary is passed using the tomcat5.0.28 test, and the Tomcat installation path is C:\Tomcat

After the default installation, Tomcat's home directory is the Webapps/root directory, and if we want to change Tomcat's home directory, we can do this:

1. Open C:\Tomcat\conf\server.xml and add code between :

<context path= "" docbase= "E:\tomcatApp\JeasyCMS" debug= "0" reloadable= "true" crosscontext= "true"/>

This restarts Tomcat, and our home directory is set to jeasycms this project.

2. In addition Tomcat will generate a C:\Tomcat\conf\Catalina\localhost directory, which automatically generates a root.xml (root) file, we open the file can see the code:

3. Note: The same is true when we create a virtual directory, so that only the path property of the context label is not empty.

4. We set up the virtual directory and the home directory, will be in the C:\Tomcat\conf\Catalina\localhost directory to generate the corresponding XML file, so when we are in the server. After deleting the home directory and the virtual directory settings in the XML, if the system has not yet taken effect, we will have to see if the XML file in this directory has been deleted, and if it has not been deleted, it will still work for Tomcat and we must delete it manually.

5. Based on the 4th, through the test I found that whenever we visited an address, Tomcat first went to the C:\Tomcat\conf\Catalina\localhost directory to see if there were any XML files in the home directory or virtual directory, Accessed by the path in XML, if there is no XML file, go to the server. XML file to see if the context tag is configured, and if the background tag is configured, a corresponding XML file is generated under the C:\Tomcat\conf\Catalina\localhost directory for the next direct validation and no longer accessing the server. XML, while opening the path specified in the context, if the server. The context tag is not configured in the XML, and the Access error page is returned.

6. Based on the 5th, we can actually create an XML file directly under C:\Tomcat\conf\Catalina\localhost for the home directory or virtual directory, without having to modify the server. XML can be configured to configure the home directory and the virtual directory, the specific XML format can be as follows:

<?Xml version='1.0' encoding='utf-8'?>
<Context crossContext="true" docBase="E:/tomcatApp/JeasyCMS" path="" reloadable="true">
</Context>

Whether the configuration of the home directory or the configuration of the virtual directory depends on the value of the path. In addition, the home directory filename must be root.xml (root), and the virtual directory's file name and virtual directory name are consistent and lowercase, for example:

<?Xml version='1.0' encoding='utf-8'?>
<Context crossContext="true" docBase="E:/tomcatApp/JeasyCMS" path="\cms" reloadable="true">
</Context>

The above defines a virtual directory named: CMS, while saving the above text as a CMS. XML file.

7. The above living directory is configured so that you can access the following address:

http://localhost:8080/(Access home directory)

Http://localhost:8080/cms (access to a virtual directory named CMS)

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.