I think this question had been asked before. But when I searched the
tomcat user group, I don't find a satisfactory answer.
Here is my question: How to configure Apache & Tomcat so that Apache
handles static content for virtual host with more than one web
applications?
My web application directories are as following:
/webapps/
/webapps/webappA/
/webapps/webappB/
/webapps/ROOT/
I have three web applications (contexts): the default(""),
webappA("/webappA"), and webappB("/webappB"). Each application has both
static content and dynamic content (JSP/servlet).
in Apache httpd.conf, I have the following virtual host definition:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.myserver.com
DocumentRoot "F:/Tomcat5.5/webapps"
JkMount /servlet/* worker1
JkMount /*.jsp worker1
</VirtualHost>
With this configuration, everything works, except that the static
content for the default application (/ROOT) can't be loaded by Apache
because Apache can't find the content.
If I change the DocumentRoot to:
DocumentRoot "F:/Tomcat5.5/webapps/ROOT"
The static content for the default application can be loaded by Apache,
but the static content for the other two web apps can't be loaded
(outside of DocumentRoot).
How can I configure virtual host so that the above problem can be
solved?
I did figure out a workaround, here it is:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.myserver.com
DocumentRoot "F:/Tomcat5.5/webapps/ROOT"
Alias /webappA/ F:/Tomcat5.5/webapps/webappA
Alias /webappB/ F:/Tomcat5.5/webapps/webappB
JkMount /servlet/* worker1
JkMount /*.jsp worker1
</VirtualHost>
With the above configuration, all static / dynamic content for all the
three web apps can be loaded properly. However, is this a standard /
recommended configuration?
Your help will be greatly appreciated!
Best Regard,
Hua Hou