How to change the ROOT application?

后端 未结 13 1339
终归单人心
终归单人心 2020-11-22 16:16

I\'m trying to change the default application of a Tomcat 6 webserver to a different application than \"ROOT\" (inside webapps folder). What is the best way to do this?

相关标签:
13条回答
  • 2020-11-22 16:44

    Adding a <Context> tag in the <Host> tag in server.xml for Tomcat 6 will resolve the problem.

    If you use path="" empty you can use a URL like http://localhost/first.do.

    In the context tag set attributes docBase="E:\struts-ITRCbook\myStrutsbook" and reloadable="true", then end the context tag.

    It should look something like this:

    <Host name="localhost"  appBase="webapps" 
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
        <Context path="" docBase="E:\struts-ITRCbook\myStrutsbook" reloadable="true">
        </Context>
    </Host>
    
    0 讨论(0)
  • 2020-11-22 16:45

    In Tomcat 7 (under Windows server) I didn't add or edit anything to any configuration file. I just renamed the ROOT folder to something else and renamed my application folder to ROOT and it worked fine.

    0 讨论(0)
  • 2020-11-22 16:46

    In Tomcat 7 with these changes, i'm able to access myAPP at / and ROOT at /ROOT

    <Context path="" docBase="myAPP"/>
    <Context path="ROOT" docBase="ROOT"/>
    

    Add above to the <Host> section in server.xml

    0 讨论(0)
  • 2020-11-22 16:48

    According to the Apache Tomcat docs, you can change the application by creating a ROOT.xml file. See this for more info:

    http://tomcat.apache.org/tomcat-6.0-doc/config/context.html

    "The default web application may be defined by using a file called ROOT.xml."

    0 讨论(0)
  • 2020-11-22 16:49

    I've got a problem when configured Tomcat' server.xml and added Context element. He just doesn't want to use my config: http://www.oreillynet.com/onjava/blog/2006/12/configuration_antipatterns_tom.html

    If you're in a Unix-like system:

    1. mv $CATALINA_HOME/webapps/ROOT $CATALINA_HOME/webapps/___ROOT
    2. ln -s $CATALINA_HOME/webapps/your_project $CATALINA_HOME/webapps/ROOT

    Done.

    Works for me.

    0 讨论(0)
  • 2020-11-22 16:50

    You can do this in a slightly hack-y way by:

    1. Stop Tomcat
    2. Move ROOT.war aside and rm -rf webapps/ROOT
    3. Copy the webapp you want to webapps/ROOT.war
    4. Start Tomcat
    0 讨论(0)
提交回复
热议问题