Tomcat 虚拟主机配置
[代码]以下的内容就是在Tomcat的webapps目录下新建一个www文件夹作为www.oschina.net这个域名的主目录
1
<Hostname="www.oschina.net"debug="0"appBase="webapps"unpackWARs="true"autoDeploy="true"xmlValidation="false"xmlNamespaceAware="false">
2
<Contextpath=""docBase="www"debug="0"reloadable="true"crossContext="true"/>
3
<Loggerclassname="org.apache.catalina.logger.FileLogger"directory="logs"prefix="oschina_log."suffix=".txt"
4
timestamp="true"/>
5
</Host>
[代码]以下内容的意思就是在C盘test文件夹下面建立一个www文件夹作为www.oschina.net这个域名的主目录
1
<Hostname="test.5sai.net.cn"debug="0"appBase="C:\\test\www"unpackWARs="true"autoDeploy="true">
2
<Contextpath=""docBase="."/>
3
<Valveclassname="org.apache.catalina.valves.AccessLogValve"directory="logs"prefix="oschina_log."
4
5
suffix=".txt"pattern="common"resolveHosts="false"/>
6
<Loggerclassname="org.apache.catalina.logger.FileLogger"directory="logs"prefix="oschina_log."suffix=".txt"timestamp="true"/>
7
</Host>
[代码]如果是linux系统的/var/www作为www.oschina.net这个域名的主目录的话内容如下:
1
<Hostname="www.oschina.net"debug="0"appBase="/var/www"unpackWARs="true"autoDeploy="true">
2
<Contextpath=""docBase="."/>
3
<Valveclassname="org.apache.catalina.valves.AccessLogValve"directory="logs"prefix="oschina_log."
4
5
suffix=".txt"pattern="common"resolveHosts="false"/>
6
<Loggerclassname="org.apache.catalina.logger.FileLogger"directory="logs"prefix="oschina_log."suffix=".txt"timestamp="true"/>
7
</Host>
[代码]域名www.oschina.net的主目录为/var/www该站点的所有访问LOG放在/ar/log/tomcat里面
01
<Hostname="www.oschina.net"debug="0"unpackWARs="true">
02
<Valveclassname="org.apache.catalina.valves.AccessLogValve"
03
directory="/var/log/tomcat"prefix="www_5sai_access_log."suffix=".txt"
04
pattern="common"/>
05
<Loggerclassname="org.apache.catalina.logger.FileLogger"
06
directory="/var/log/tomcat"prefix="oschina_log."suffix=".txt"
07
timestamp="true"/>
08
09
<Contextpath=""docBase="/var/www"debug="0"reloadable="true"/>
10
</Host>
[代码]同时写多个主机
1
<Hostname="www.oschina.net"debug="0"appBase="D:\Tomcat50\webapps\www.oschina.net">
2
<Contextpath=""docBase="."debug="0"/>
3
</Host>
4
<Hostname="my.oschina.net"debug="0"appBase="D:\Tomcat50\webapps\my.oschina.net">
5
<Contextpath=""docBase="."debug="0"/>
6
</Host>
原文:http://www.oschina.net/code/snippet_12_2034