开发者

Deploy war on Tomcat without the war name in the URL

I built a war file called myapp.war and deployed it on Tomcat. I've changed the port from 8080 to 80 so I can then get to it at example.com/myapp (where example.com is my host).

How can I get configure the application so that when I go to example.com, it shows my app? I don't want to just redirect from 开发者_高级运维example.com to example.com/myapp - I don't want to have myapp in the URL.

Do I have to set up Apache to serve the pages like this, or can I do it with a virtual host in the Tomcat configuration?


All you need to do is name your war ROOT.war.


Here are two possible method:

  1. Rename your war to ROOT.war
  2. No need to rename. Go to CATALINA_BASE/conf/server.xml Find Host element and set autoDeploy="false" deployOnStartup="false" then add <Context path="" docBase="your_project_name"/> in the end like:

expamle#2:

  <Host name="localhost"  appBase="webapps"
        unpackWARs="true" autoDeploy="false" deployOnStartup="false"> 

    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
           prefix="localhost_access_log." suffix=".txt"
           pattern="%h %l %u %t &quot;%r&quot; %s %b" />
    <Context path="" docBase="your_project_name"/><!--Add this-->
  </Host>


You don't have to setup an Apache front-end or to configure virtual hosting in Tomcat for this. Instead, just deploy your webapp to the "root context". To do this, refer to How do I make my web application be the Tomcat default application ? on the Tomcat Wiki. They describe the three possible methods so you'll be able to pickup the one that suits the best your needs.


Check out the Tomcat virtual hosting howto.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜