Virtual directory configuration for Apache Tomcat 5.0.2x

Source: Internet
Author: User
Tags port number tomcat apache tomcat

After you install Tomcat, the default is Tomcat's home page, so how do you point the home page, "http://127.0.0.1:8080", to our own home page? This is going to set up Tomcat's virtual directory.

In a previous version of Tomcat, such as "Tomcat 5.0.14" and previous versions, expand "tomcat>conf", you can see a "server.xml" file, open it with Notepad, in the last part of the document has a commented "< Context> tab, use this tab to configure the virtual directory. But for some reason, this tag was added to the later version of Tomcat and we had to manually add this tag.

Now for a specific description of the virtual directory configuration:

Expand tomcat5.x.x>conf and use Notepad to open "server.xml" to move the cursor to the end of the file with the following code:

<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="localhost_log." suffix=".txt" timestamp="true"/>
</Host>
</Engine>
</Service>
</Server>

Add the following code before the </Host> label

<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="localhost_log." suffix=".txt" timestamp="true"/>
<Context path="" docBase="E:\myapps" debug="0"></Context>
<Context path="/test" docBase="F:\mytest" debug="0" ></Context>
</Host>
</Engine>
</Service>
</Server>

The red part of the code is the code that is just added, where "path" refers to the directory in the URL, and if it is empty, it maps to "http://127.0.0.1:8080" (the Tomcat default port is 8080), and if "/test" is mapped to "http:// 127.0.0.1:8080/test ". This way in the browser to enter the above Web site can be accessed, of course, you can add other virtual directories.

By the way, change Tomcat's port number to the default "80", only to be changed in the "Server.xml" file:

<Connector port="8080" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" debug="0" connectionTimeout="20000"
disableUploadTimeout="true" />

Change "8080" in the code to "80" to use IE default port access, that is, enter the URL can not add a port number such as: "http://127.0.0.1."

Related Article

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.