- old way to setup a vhost in
server.xml
<Host name="www.mysite.com" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context path="" docBase="sample" reloadable="true" />
this works, I can see contents in the <tomcat_home>/webapps/sample.
- as mentioned in Tomcat docs.
It is NOT recommended to place elements directly in the server.xml file. This is because it makes modifying the Context configuration more invasive since the main conf/server.xml file cannot be reloaded without restarting Tomcat. Default Context elements (see below) will also overwrite the configuration of any elements placed directly in server.xml. To prevent this, the override attribute of the element defined in server.xml should be set to true.
Individual Context elements may be explicitly defined:
In an individual file at /META-INF/context.xml inside the application files. Optionally (based on the Host's copyXML attribute) this may be copied to $CATALINA_BASE/conf/[enginename]/[hostname]/ and renamed to application's base file name plus a ".xml" extension.
In individual files (with a ".xml" extension) in the $CATALINA_BASE/conf/[enginename]/[hostname]/ directory. The context path and version will be derived from the base name of the file (the file name less the .xml extension). This file will always take precedence over any context.xml file packaged in the web application's META-INF directory.
So I create someting in server.xml
<Host name="www.mysite.com" appBase="webapps"
unpackWARs="true" autoDeploy="true">
</Host>
and then place a context.xml
in <tomcat_home/conf/Catalina/www.mysite.com/
, and its content is
<Context docBase="sample" reloadable="true" />
This don't work, it return a 404
page.
So what's the right way to set vhost by context ?
Thanks.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…