TomCat 多虚拟站点配置
2008-02-23 08:09:45来源:互联网 阅读 ()
参考资料: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.
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash