网站首页
JSP空间
动态资讯
开源项目
技术文档
资源下载
J2EE资源
客户论坛
在线支付
 
  技术文档>>专题栏目>>Tomcat专题>查看文档  
  Tomcat多虚拟站点   精华  
  文章作者:未知  文章来源:未知  
  查看:485次  录入:管理员--2007-03-12  
  在网络上看了许久,没有一个真正可以解决TomCat多虚拟站点的配置问题的,经过试验和参考官方网站资料,终于解决了这个问题.
  参考资料:Apache Tomcat文档http://tomcat.apache.org/tomcat-5.0-doc/config/host.html

  在文中有这么一段话:
  One or more Host elements are nested inside an Engine element. Inside the Host element, you can nest Context elements for the web applications associated with this virtual host. Exactly one of the Hosts associated with each Engine MUST have a name matching the defaultHost attribute of that Engine.

  译文:Engine元素中需要一个或多个Host元素,在Host元素里面,你必需有Context元素让网站应用程序与虚拟主机连接上,严密地说,每一个主机所关联的引擎必须有一个名字跟那个引擎默认的主机属性匹配 .
  可知,在Engine元素里面可以有多个Host,那么说,可以有在一个Engine里面设置多个服务器了,这正是我们需要的.每个Host元素里面要有一个Context元素.
  根据conf\server.xml里面的说明和范例,我样可以编写出下面一个配置文件:

  1<!-- Example Server Configuration File -->
  2<!-- Note that component elements are nested corresponding to their
  3     parent-child relationships with each other -->
  4
  5<!-- A "Server" is a singleton element that represents the entire JVM,
  6     which may contain one or more "Service" instances.  The Server
  7     listens for a shutdown command on the indicated port.
  8
  9     Note:  A "Server" is not itself a "Container", so you may not
 10     define subcomponents such as "Valves" or "Loggers" at this level.
 11 -->
 12
 13<Server port="8005" shutdown="SHUTDOWN">
 14
 15  <!-- Comment these entries out to disable JMX MBeans support used for the
 16       administration web application -->
 17  <Listener className="org.apache.catalina.core.AprLifecycleListener" />
 18  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
 19  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
 20  <Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
 21
 22  <!-- Global JNDI resources -->
 23  <GlobalNamingResources>
 24
 25    <!-- Test entry for demonstration purposes -->
 26    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
 27
 28    <!-- Editable user database that can also be used by
 29         UserDatabaseRealm to authenticate users -->
 30    <Resource name="UserDatabase" auth="Container"
 31              type="org.apache.catalina.UserDatabase"
 32       description="User database that can be updated and saved"
 33           factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
 34          pathname="conf/tomcat-users.xml" />
 35
 36  </GlobalNamingResources>
 37
 38  <!-- A "Service" is a collection of one or more "Connectors" that share
 39       a single "Container" (and therefore the web applications visible
 40       within that Container).  Normally, that Container is an "Engine",
 41       but this is not required.
 42
 43       Note:  A "Service" is not itself a "Container", so you may not
 44       define subcomponents such as "Valves" or "Loggers" at this level.
 45   -->
 46
 47  <!-- Define the Tomcat Stand-Alone Service -->
 48  <Service name="Catalina">
 49
 50    <!-- A "Connector" represents an endpoint by which requests are received
 51         and responses are returned.  Each Connector passes requests on to the
 52         associated "Container" (normally an Engine) for processing.
 53
 54         By default, a non-SSL HTTP/1.1 Connector is established on port 8080.
 55         You can also enable an SSL HTTP/1.1 Connector on port 8443 by
 56         following the instructions below and uncommenting the second Connector
 57         entry.  SSL support requires the following steps (see the SSL Config
 58         HOWTO in the Tomcat 5 documentation bundle for more detailed
 59         instructions):
 60         * If your JDK version 1.3 or prior, download and install JSSE 1.0.2 or
 61           later, and put the JAR files into "$JAVA_HOME/jre/lib/ext".
 62         * Execute:
 63             %JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA (Windows)
 64             $JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA  (Unix)
 65           with a password value of "changeit" for both the certificate and
 66           the keystore itself.
 67
 68         By default, DNS lookups are enabled when a web application calls
 69         request.getRemoteHost().  This can have an adverse impact on
 70         performance, so you can disable it by setting the
 71         "enableLookups" attribute to "false".  When DNS lookups are disabled,
 72         request.getRemoteHost() will return the String version of the
 73         IP address of the remote client.
 74    -->
 75
 76    <!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
 77    <Connector
 78port="80"               maxHttpHeaderSize="8192"
 79               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
 80               enableLookups="false" redirectPort="8443" acceptCount="100"
 81               connectionTimeout="20000" disableUploadTimeout="true"  URIEncoding="GB2312"/>
 82    <!-- Note : To disable connection timeouts, set connectionTimeout value
 83     to 0 -->
 84
 85    <!-- Note : To use gzip compression you could set the following properties :
 86
 87               compression="on"
 88               compressionMinSize="2048"
 89               noCompressionUserAgents="gozilla, traviata"
 90               compressableMimeType="text/html,text/xml"
 91    -->
 92
 93    <!-- Define a SSL HTTP/1.1 Connector on port 8443 -->
 94    <!--
 95    <Connector port="8443" maxHttpHeaderSize="8192"
 96               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
 97               enableLookups="false" disableUploadTimeout="true"
 98               acceptCount="100" scheme="https" secure="true"
 99               clientAuth="false" sslProtocol="TLS" />
100    -->
101
102    <!-- Define an AJP 1.3 Connector on port 8009 -->
103    <Connector port="8009"
104               enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
105
106    <!-- Define a Proxied HTTP/1.1 Connector on port 8082 -->
107    <!-- See proxy documentation for more information about using this. -->
108    <!--
109    <Connector port="8082"
110               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
111               enableLookups="false" acceptCount="100" connectionTimeout="20000"
112               proxyPort="80" disableUploadTimeout="true" />
113    -->
114
115    <!-- An Engine represents the entry point (within Catalina) that processes
116         every request.  The Engine implementation for Tomcat stand alone
117         analyzes the HTTP headers included with the request, and passes them
118         on to the appropriate Host (virtual host). -->
119
120    <!-- You should set jvmRoute to support load-balancing via AJP ie :
121    <Engine name="Standalone" defaultHost="localhost" jvmRoute="jvm1">
122    -->
123
124    <!-- Define the top level container in our container hierarchy -->
125    <Engine name="Catalina" defaultHost="ycoe.vicp.net">
126
127      <!-- The request dumper valve dumps useful debugging information about
128           the request headers and cookies that were received, and the response
129           headers and cookies that were sent, for all requests received by
130           this instance of Tomcat.  If you care only about requests to a
131           particular virtual host, or a particular application, nest this
132           element inside the corresponding <Host> or <Context> entry instead.
133
134           For a similar mechanism that is portable to all Servlet 2.4
135           containers, check out the "RequestDumperFilter" Filter in the
136           example application (the source for this filter may be found in
137           "$CATALINA_HOME/webapps/examples/WEB-INF/classes/filters").
138
139           Request dumping is disabled by default.  Uncomment the following
140           element to enable it. -->
141      <!--
142      <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
143      -->
144
145      <!-- Because this Realm is here, an instance will be shared globally -->
146
147      <!-- This Realm uses the UserDatabase configured in the global JNDI
148           resources under the key "UserDatabase".  Any edits
149           that are performed against this UserDatabase are immediately
150           available for use by the Realm.  -->
151      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
152             resourceName="UserDatabase"/>
153
福建JSP技术网 -->
 
 
上一篇: Tomcat5.5连接池的配置    下一篇: Tomcat配置技巧Top 10
  相关文档
Tomcat启动分析 03-12
设置tomcat admin 03-12
Eclipse3.2+Tomcat5.5.17+Oracle9配置 03-12
Linux下Tomcat的安装 03-12
安装第二个Tomcat完成后,到安装目录下的conf子目录中打开serv.. 03-12
Tomcat服务器端SSL的配置(JKS和PKCS12) 03-12
整合vista iis7 与 tomcat 5.5的配置方法 03-12
Tomcat配置技巧Top 10 03-12
TOMCAT5在WINDOWS下的系统服务相关的命令行 03-12
tomcat下get方式提交请求乱码解决办法 03-12
tomcat的配置和管理问题总结 03-12
使用tomcat自带的连接池 03-12
用Eclipse3.2 + Myeclipse5.0GA + Tomcat5.5.17 + j2sdk1.5 搭.. 03-12
apache2与tomcat5.5整合 03-12
Tomcat类加载机制 03-12
Tomcat多虚拟站点 03-12
Apache HTTP Server 与 Tomcat 的三种连接方式介绍息 03-12
Tomcat 5.5 开发 Servlet 和 JavaBean 的配置 03-12
Tomcat 5.5开发Servlet和JavaBean的配置 03-12
解决Tomcat 中文文件下载乱码问题 03-12
返回首页 | 关于我们 | J网章程 | JSP空间合租 | 客服中心 | 免责声明 | 常见问题 | 参观机房
本站主机空间代理至厦门市华众网络科技有限公司
《中华人民共和国增值电信业务经营许可证》
编号:闽B2-20050079
@2005-2008福建JSP技术网 版权所有 闽ICP备05000928号
技术电话:13616026886
邮箱:admin@fjjsp.com 站长QQ,点击这里给我发消息