分享
 
 
 

TomCat 多虚拟站点配置

王朝system·作者佚名  2006-11-24
窄屏简体版  字體: |||超大  

在网络上找了许久,没有一个真正可以解决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 &n

[1] [2] [3] [4] [5] [6] [7] 下一页

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有