配置Tomcat虚拟主机.docx
- 文档编号:3814792
- 上传时间:2022-11-25
- 格式:DOCX
- 页数:21
- 大小:606.06KB
配置Tomcat虚拟主机.docx
《配置Tomcat虚拟主机.docx》由会员分享,可在线阅读,更多相关《配置Tomcat虚拟主机.docx(21页珍藏版)》请在冰豆网上搜索。
配置Tomcat虚拟主机
配置Tomcat虚拟主机
注,在说Tomcat虚拟主机之前,咱们来详细的看看默认的配置文件,虽然在上一篇博客中全部有讲解,在这篇博客中我还是再和大家简单说一下,下面是默认配置文件。
大家可以看到,绝大部分的配置文件是注释,包含在
---->、全是注释。
下面我们就来具体的看看,注释我们就不说了,说具体的定义的内容
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
[root@tomcat~]#cat/usr/local/tomcat/conf/server.xml
xmlversion='1.0' encoding='utf-8'?
>
--
LicensedtotheApacheSoftwareFoundation(ASF)underoneor more
contributorlicenseagreements.SeetheNOTICE file distributedwith
thiswork for additionalinformationregardingcopyrightownership.
TheASFlicensesthis file toYouundertheApacheLicense,Version2.0
(the "License");youmaynotusethis file except in compliancewith
theLicense.YoumayobtainacopyoftheLicenseat
http:
//www.apache.org/licenses/LICENSE-2.0
Unlessrequiredbyapplicablelaworagreedto in writing,software
distributedundertheLicenseisdistributedonan "ASIS" BASIS,
WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied.
SeetheLicense for thespecificlanguagegoverningpermissionsand
limitationsundertheLicense.
-->
--Note:
A "Server" isnotitselfa "Container",soyoumaynot
definesubcomponentssuchas "Valves" atthislevel.
Documentationat /docs/config/server.html
-->
--Securitylistener.Documentationat /docs/config/listeners.html
-->
--APRlibraryloader.Documentationat /docs/apr.html-->
--InitializeJasperpriortowebappsareloaded.Documentationat /docs/jasper-howto.html-->
--Preventmemoryleaksduetouseofparticularjava/javax APIs-->
--GlobalJNDIresources
Documentationat /docs/jndi-resources-howto.html
-->
--Editableuserdatabasethatcanalsobeusedby
UserDatabaseRealmtoauthenticate users
-->
type="org.apache.catalina.UserDatabase" description="Userdatabasethatcanbeupdatedandsaved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml" /> --A "Service" isacollectionofoneor more "Connectors" thatshare asingle "Container" Note: A "Service" isnotitselfa "Container", soyoumaynotdefinesubcomponentssuchas "Valves" atthislevel. Documentationat /docs/config/service.html --> --Theconnectorscanuseasharedexecutor,youcandefineoneor more namedthreadpools--> -- maxThreads="150" minSpareThreads="4"/> --> --A "Connector" representsanendpointby which requestsarereceived andresponsesarereturned.Documentationat: JavaHTTPConnector: /docs/config/http.html(blocking&non-blocking) JavaAJPConnector: /docs/config/ajp.html APR(HTTP/AJP)Connector: /docs/apr.html Defineanon-SSLHTTP/1.1Connectoronport8080 --> connectionTimeout="20000" redirectPort="8443" /> #这里定义了一个连接器,协议为http,端口为8080,最大连接超时为20s,这里还定义了一个SSL的重定向端口8443。 我们可以根据需要进行修改。 一般我们都用80端口与443端口。 --A "Connector" usingthesharedthreadpool--> -- port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> --> --DefineaSSLHTTP/1.1Connectoronport8443 ThisconnectorusestheJSSEconfiguration,whenusingAPR,the connectorshouldbeusingtheOpenSSLstyleconfiguration described in theAPRdocumentation--> -- maxThreads="150" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" /> #这里定义了一个SSL的案例,主要定义相关密钥与证书。 --> --DefineanAJP1.3Connectoronport8009--> --AnEnginerepresentstheentrypoint(withinCatalina)thatprocesses everyrequest.TheEngineimplementation for Tomcatstandalone analyzestheHTTPheadersincludedwiththerequest,andpassesthem ontotheappropriateHost(virtualhost). Documentationat /docs/config/engine.html--> --Youshould set jvmRoutetosupportload-balancingviaAJPie: --> --Forclustering,pleasetakea look atdocumentationat: /docs/cluster-howto.html(simplehowto) /docs/config/cluster.html(referencedocumentation)--> -- --> --UsetheLockOutRealmtopreventattemptstoguessuserpasswords viaabrute-forceattack--> --ThisRealmusestheUserDatabaseconfigured in theglobalJNDI resourcesunderthekey "UserDatabase".Anyedits thatareperformedagainstthisUserDatabaseareimmediately available for usebytheRealm.--> resourceName="UserDatabase"/> unpackWARs="true" autoDeploy="true"> #这里就是定义的虚拟主机。 --SingleSignOnvalve,shareauthenticationbetweenwebapplications Documentationat: /docs/config/valve.html--> -- --> --Accesslogprocessesallexample. Documentationat: /docs/config/valve.html Note: Thepatternusedisequivalenttousingpattern="common" --> prefix="localhost_access_log." suffix=".txt" pattern="%h%l%u%t"%r"%s%b" /> #这里定义了一个日志相关的属性。 好了,在这里我们又简单的说明一下,配置文件下面我们就来具体演示一下怎么配置虚拟主机。 首先,我们来修改一下配置文件, [root@tomcatconf]#vimserver.xml #增加下面几行 1 2 3 4 unpackWARs="true" autoDeploy="true"> 接下来我们来创建文档目录与测试页面, 1 2 3 4 5 6 7 8 9 10 11 12 13 [root@tomcat~]#mkdir-pv/web/webapp [root@tomcat~]#cd/web/webapp [root@tomcatwebapp]#vimindex.jsp <%@pagelanguage="java" %> <%@page import="java.util.*" %> <%out.println("Welcometotest.Site,");%> 现在我们来测试一下我们修改的配置文件, 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [root@tomcat~]#servicetomcatstop UsingCATALINA_BASE: /usr/local/tomcat UsingCATALINA_HOME: /usr/local/tomcat UsingCATALINA_TMPDIR: /usr/local/tomcat/temp UsingJRE_HOME: /usr UsingCLASSPATH: /usr/local/tomcat/bin/bootstrap.jar: /usr/local/tomcat/bin/tomcat-juli.jar ^[[A[root@tomcatservicetomcatconfigtest UsingCATALINA_BASE: /usr/local/tomcat UsingCATALINA_HOME: /usr/local/tomcat UsingCATALINA_TMPDIR: /usr/local/tomcat/temp UsingJRE_HOME: /usr UsingCLASSPATH: /usr/local/tomcat/bin/bootstrap.jar: /usr/local/tomcat/bin/tomcat-juli.jar Sep22,20132: 15: 47AMorg.apache.catalina.core.AprLifecycleListenerinit INFO: TheAPRbasedApacheTomcatNativelibrary which allowsoptimalperformance in productionenvironmentswasnotfoundonthejava.library.path: /usr/java/packages/lib/amd64: /usr/lib64: /lib64: /lib: /usr/lib Sep22,20132: 15: 47AMorg.apache.coyote.AbstractProtocolinit INFO: InitializingProtocolHandler["http-bio-80"] Sep22,20132: 15: 47AMorg.apache.coyote.AbstractProtocolinit INFO: InitializingProtocolHandler["ajp-bio-8009"] Sep22,20132: 15: 47AMorg.apache.catalina.startup.Catalinaload INFO: Initializationprocessed in 1294ms 注,大家可以看到,我们这里没有报错,说明配置都是正确的,若配置有错误,会在最后一行提醒你。 再下面我们来启动Tomcat并测试一下, 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 [root@tomcat~]#servicetomcatstart UsingCATALINA_BASE: /usr/local/tomcat UsingCATALINA_HOME: /usr/local/tomcat UsingCATALINA_TMPDIR: /usr/local/tomcat/temp UsingJRE_HOME: /usr UsingCLASSPATH: /usr/local/tomcat/bin/bootstrap.jar: /usr/local/tomcat/bin/tomcat-juli.jar [root@tomcat~]#netstat-ntulp ActiveInternetconnections(onlyservers) ProtoRecv-QSend-QLocalAddress ForeignAddress State PID/Program name tcp 0 00.0.0.0: 22 0.0.0.0: * LISTEN 1044/sshd tcp 0 0127.0.0.1: 25 0.0.0.0: * LISTEN 1121/master tcp 0 0127.0.0.1: 6010 0.0.0.0: * LISTEN 13368/sshd tcp 0
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 配置 Tomcat 虚拟主机