Wednesday, April 25, 2012

Custom Application Path in Tomcat

How to configure different paths for each web application running in Tomcat?


This was a question that came up in TechLink and I thought that it'd be nice to share the answer with you and also to write it here as a reminder to myself.


All what is necessary is to edit the server.xml to add a Host section per site inside the Engine tag, see an example below:


<!-- Preview host -->
<Host name="tomcatpreviewdeployer.local"  appBase="C:\workarea\websites\preview\java\deployer" unpackWARs="true" autoDeploy="true">
            <Context path="" docBase="" debug="0" reloadable="true"/>
            <Valve className="org.apache.catalina.valves.AccessLogValve" directory="C:\Tridion\log\preview\java"
               prefix="tomcatpreview_deployer_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
</Host>
<Host name="tomcatpreviewsite.local"  appBase="C:\workarea\websites\preview\java\site" unpackWARs="true" autoDeploy="true">
            <Context path="" docBase="" debug="0" reloadable="true"/>
            <Valve className="org.apache.catalina.valves.AccessLogValve" directory="C:\Tridion\log\preview\java"
               prefix="tomcatpreview_site_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
</Host>
     
<!-- Live host -->
<Host name="tomcatlivedeployer.local"  appBase="C:\workarea\websites\live\java\deployer" unpackWARs="true" autoDeploy="true">
            <Context path="" docBase="" debug="0" reloadable="true"/>
            <Valve className="org.apache.catalina.valves.AccessLogValve" directory="C:\Tridion\log\live\java"
               prefix="tomcatlive_deployer_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
</Host>
<Host name="tomcatlivesite.local"  appBase="C:\workarea\websites\preview\java\site" unpackWARs="true" autoDeploy="true">
            <Context path="" docBase="" debug="0" reloadable="true"/>
            <Valve className="org.apache.catalina.valves.AccessLogValve" directory="C:\Tridion\log\preview\java"
               prefix="tomcatlive_site_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
</Host>             

7 comments:

  1. I like the helpful info you provide in your articles. I’ll bookmark your weblog and check again here regularly....We are intimating the direct link to know your Sarkari Result Directly. Aspirants can additionally get the complete Data about the Sakari Result likely, result releasing date & Upcoming Sarkari Result All India &When the Official keys & Cut Off Which are released by the Authorities.

    ReplyDelete