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>             

1 comment: