Tomcat virtual hosting, does each host need it's own subdirectory off webapps?
posted 7 years ago
I am using the Apache web server 2.2, mod_jk 1.2, and Tomcat 6 to serve several webapps, each on a different subdomain.
I deploy the webapps as .war files into the tomcat/webapps directory. I would like to keep this arrangement if possible as it makes things simpler for support staff if they have to update or redeploy a webapp.
Apache/mod_jk is working fine, as is direct access to the webapps via Tomcat, but I haven't fully understood the Tomcat documentation regarding Hosts, Contexts and Autodeployment.
This is what I've tried:
- Set each server.xml Host appBase to the full path of the deployed webapp, Tomcat doesn't find the context descriptor of the webapp. Testing the URL gives me a blank page.
- Add a server.xml Context element to each host. This works, but requires a Tomcat restart each time a webapp is deployed, and is not recommended in the documentation.
- Set each Host appBase to the base directory (tomcat/webapps/) then how can the Host tell which webapp it should serve?
Is the only option to give each Virtual Host its own subdirectory and deploy war files under the correct subdirectory? I'm guessing it is, but it would be great to just drop war files in a single location and have them autodeploy in their corresponding vhosts.