配置Tomcat 域名解析 tomcat/conf server.xml

  1 初始文件:
  2 <?xml version=‘1.0‘ encoding=‘utf-8‘?>
  3 <!--
  4   Licensed to the Apache Software Foundation (ASF) under one or more
  5   contributor license agreements.  See the NOTICE file distributed with
  6   this work for additional information regarding copyright ownership.
  7   The ASF licenses this file to You under the Apache License, Version 2.0
  8   (the "License"); you may not use this file except in compliance with
  9   the License.  You may obtain a copy of the License at
 10
 11       http://www.apache.org/licenses/LICENSE-2.0
 12
 13   Unless required by applicable law or agreed to in writing, software
 14   distributed under the License is distributed on an "AS IS" BASIS,
 15   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 16   See the License for the specific language governing permissions and
 17   limitations under the License.
 18 -->
 19 <!-- Note:  A "Server" is not itself a "Container", so you may not
 20      define subcomponents such as "Valves" at this level.
 21      Documentation at /docs/config/server.html
 22  -->
 23 <Server port="8005" shutdown="SHUTDOWN">
 24
 25   <!--APR library loader. Documentation at /docs/apr.html -->
 26   <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
 27   <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
 28   <Listener className="org.apache.catalina.core.JasperListener" />
 29   <!-- Prevent memory leaks due to use of particular java/javax APIs-->
 30   <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
 31   <!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
 32   <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
 33   <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
 34
 35   <!-- Global JNDI resources
 36        Documentation at /docs/jndi-resources-howto.html
 37   -->
 38   <GlobalNamingResources>
 39     <!-- Editable user database that can also be used by
 40          UserDatabaseRealm to authenticate users
 41     -->
 42     <Resource name="UserDatabase" auth="Container"
 43               type="org.apache.catalina.UserDatabase"
 44               description="User database that can be updated and saved"
 45               factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
 46               pathname="conf/tomcat-users.xml" />
 47   </GlobalNamingResources>
 48
 49   <!-- A "Service" is a collection of one or more "Connectors" that share
 50        a single "Container" Note:  A "Service" is not itself a "Container",
 51        so you may not define subcomponents such as "Valves" at this level.
 52        Documentation at /docs/config/service.html
 53    -->
 54   <Service name="Catalina">
 55
 56     <!--The connectors can use a shared executor, you can define one or more named thread pools-->
 57     <!--
 58     <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
 59         maxThreads="150" minSpareThreads="4"/>
 60     -->
 61
 62
 63     <!-- A "Connector" represents an endpoint by which requests are received
 64          and responses are returned. Documentation at :
 65          Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
 66          Java AJP  Connector: /docs/config/ajp.html
 67          APR (HTTP/AJP) Connector: /docs/apr.html
 68          Define a non-SSL HTTP/1.1 Connector on port 8080
 69     -->
 70     <Connector port="8080" protocol="HTTP/1.1"
 71                connectionTimeout="20000"
 72                redirectPort="8443" />
 73     <!-- A "Connector" using the shared thread pool-->
 74     <!--
 75     <Connector executor="tomcatThreadPool"
 76                port="8080" protocol="HTTP/1.1"
 77                connectionTimeout="20000"
 78                redirectPort="8443" />
 79     -->
 80     <!-- Define a SSL HTTP/1.1 Connector on port 8443
 81          This connector uses the JSSE configuration, when using APR, the
 82          connector should be using the OpenSSL style configuration
 83          described in the APR documentation -->
 84     <!--
 85     <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
 86                maxThreads="150" scheme="https" secure="true"
 87                clientAuth="false" sslProtocol="TLS" />
 88     -->
 89
 90     <!-- Define an AJP 1.3 Connector on port 8009 -->
 91     <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
 92
 93
 94     <!-- An Engine represents the entry point (within Catalina) that processes
 95          every request.  The Engine implementation for Tomcat stand alone
 96          analyzes the HTTP headers included with the request, and passes them
 97          on to the appropriate Host (virtual host).
 98          Documentation at /docs/config/engine.html -->
 99
100     <!-- You should set jvmRoute to support load-balancing via AJP ie :
101     <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
102     -->
103     <Engine name="Catalina" defaultHost="localhost">
104
105       <!--For clustering, please take a look at documentation at:
106           /docs/cluster-howto.html  (simple how to)
107           /docs/config/cluster.html (reference documentation) -->
108       <!--
109       <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
110       -->
111
112       <!-- The request dumper valve dumps useful debugging information about
113            the request and response data received and sent by Tomcat.
114            Documentation at: /docs/config/valve.html -->
115       <!--
116       <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
117       -->
118
119       <!-- This Realm uses the UserDatabase configured in the global JNDI
120            resources under the key "UserDatabase".  Any edits
121            that are performed against this UserDatabase are immediately
122            available for use by the Realm.  -->
123       <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
124              resourceName="UserDatabase"/>
125
126       <!-- Define the default virtual host
127            Note: XML Schema validation will not work with Xerces 2.2.
128        -->
129       <Host name="localhost"  appBase="webapps"
130             unpackWARs="true" autoDeploy="true"
131             xmlValidation="false" xmlNamespaceAware="false">
132
133         <!-- SingleSignOn valve, share authentication between web applications
134              Documentation at: /docs/config/valve.html -->
135         <!--
136         <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
137         -->
138
139         <!-- Access log processes all example.
140              Documentation at: /docs/config/valve.html -->
141         <!--
142         <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
143                prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
144         -->
145
146       </Host>
147     </Engine>
148   </Service>
149 </Server>
150
151 配置后的server.xml:
152 <?xml version=‘1.0‘ encoding=‘utf-8‘?>
153 <!--
154   Licensed to the Apache Software Foundation (ASF) under one or more
155   contributor license agreements.  See the NOTICE file distributed with
156   this work for additional information regarding copyright ownership.
157   The ASF licenses this file to You under the Apache License, Version 2.0
158   (the "License"); you may not use this file except in compliance with
159   the License.  You may obtain a copy of the License at
160
161       http://www.apache.org/licenses/LICENSE-2.0
162
163   Unless required by applicable law or agreed to in writing, software
164   distributed under the License is distributed on an "AS IS" BASIS,
165   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
166   See the License for the specific language governing permissions and
167   limitations under the License.
168 -->
169 <!-- Note:  A "Server" is not itself a "Container", so you may not
170      define subcomponents such as "Valves" at this level.
171      Documentation at /docs/config/server.html
172  -->
173 <Server port="8005" shutdown="SHUTDOWN">
174
175   <!--APR library loader. Documentation at /docs/apr.html -->
176   <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
177   <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
178   <Listener className="org.apache.catalina.core.JasperListener" />
179   <!-- Prevent memory leaks due to use of particular java/javax APIs-->
180   <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
181   <!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
182   <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
183   <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
184
185   <!-- Global JNDI resources
186        Documentation at /docs/jndi-resources-howto.html
187   -->
188   <GlobalNamingResources>
189     <!-- Editable user database that can also be used by
190          UserDatabaseRealm to authenticate users
191     -->
192     <Resource name="UserDatabase" auth="Container"
193               type="org.apache.catalina.UserDatabase"
194               description="User database that can be updated and saved"
195               factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
196               pathname="conf/tomcat-users.xml" />
197   </GlobalNamingResources>
198
199   <!-- A "Service" is a collection of one or more "Connectors" that share
200        a single "Container" Note:  A "Service" is not itself a "Container",
201        so you may not define subcomponents such as "Valves" at this level.
202        Documentation at /docs/config/service.html
203    -->
204   <Service name="Catalina">
205
206     <!--The connectors can use a shared executor, you can define one or more named thread pools-->
207     <!--
208     <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
209         maxThreads="150" minSpareThreads="4"/>
210     -->
211
212
213     <!-- A "Connector" represents an endpoint by which requests are received
214          and responses are returned. Documentation at :
215          Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
216          Java AJP  Connector: /docs/config/ajp.html
217          APR (HTTP/AJP) Connector: /docs/apr.html
218          Define a non-SSL HTTP/1.1 Connector on port 8080
219     -->
220     <Connector port="80" protocol="HTTP/1.1"
221               maxHttpHeaderSize="8192"
222         maxThreads="150" minSpareThreads="25"
223         maxSpareThreads="75"
224         enableLookups="false" redirectPort="8443"
225         acceptCount="100"
226         connectionTimeout="20000" disableUploadTimeout="true"
227         URIEncoding="UTF-8"/>
228  //改端口为80,运行项目时就不需要在网站路径中添加:8080,直接http://localhost/abc就行了。
229 URIEncoding="UTF-8"设定默认编码方式为UTF-8
230 URIEncoding="UTF-8"    <!-- A "Connector" using the shared thread pool-->
231     <!--
232     <Connector executor="tomcatThreadPool"
233                port="80" protocol="HTTP/1.1"
234                connectionTimeout="20000"
235                redirectPort="8443" />
236     -->
237     <!-- Define a SSL HTTP/1.1 Connector on port 8443
238          This connector uses the JSSE configuration, when using APR, the
239          connector should be using the OpenSSL style configuration
240          described in the APR documentation -->
241     <!--
242     <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
243                maxThreads="150" scheme="https" secure="true"
244                clientAuth="false" sslProtocol="TLS" />
245     -->
246
247     <!-- Define an AJP 1.3 Connector on port 8009 -->
248     <!-- <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> -->
249
250
251     <!-- An Engine represents the entry point (within Catalina) that processes
252          every request.  The Engine implementation for Tomcat stand alone
253          analyzes the HTTP headers included with the request, and passes them
254          on to the appropriate Host (virtual host).
255          Documentation at /docs/config/engine.html -->
256
257     <!-- You should set jvmRoute to support load-balancing via AJP ie :
258     <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
259     -->
260     <Engine name="Catalina" defaultHost="localhost">
261
262       <!--For clustering, please take a look at documentation at:
263           /docs/cluster-howto.html  (simple how to)
264           /docs/config/cluster.html (reference documentation) -->
265       <!--
266       <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
267       -->
268
269       <!-- The request dumper valve dumps useful debugging information about
270            the request and response data received and sent by Tomcat.
271            Documentation at: /docs/config/valve.html -->
272       <!--
273       <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
274       -->
275
276       <!-- This Realm uses the UserDatabase configured in the global JNDI
277            resources under the key "UserDatabase".  Any edits
278            that are performed against this UserDatabase are immediately
279            available for use by the Realm.  -->
280       <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
281              resourceName="UserDatabase"/>
282
283       <!-- Define the default virtual host
284            Note: XML Schema validation will not work with Xerces 2.2.
285        -->
286       <Host name="www.baidu.com" xmlNamespaceAware="false"
287          xmlValidation="false" autoDeploy="true" unpackWARs="true" appBase="webapps" debug="0">
288     <Context reloadable="true" path="" docBase="项目名称"/>
289 //这段代码绑定域名,和设定用域名默认打开的文件,假设项目名称为abc,放在webapps下,然后直接在网页地址栏输入域名:www.baidu.com 就能直接访问项目abc了。如果还有其他项目也放在webapps下,用www.baidu.com/其他项目名称,也可以访问。
290         <!-- SingleSignOn valve, share authentication between web applications
291              Documentation at: /docs/config/valve.html -->
292         <!--
293         <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
294         -->
295
296         <!-- Access log processes all example.
297              Documentation at: /docs/config/valve.html -->
298         <!--
299         <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
300                prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
301         -->
302
303       </Host>
304     </Engine>
305   </Service>
306 </Server>
时间: 2024-10-09 16:54:38

配置Tomcat 域名解析 tomcat/conf server.xml的相关文章

Tomcat源码分析——server.xml文件的加载

前言 作为Java程序员,对于tomcat的server.xml想必都不陌生.本文基于Tomcat7.0的Java源码,对server.xml文件是如何加载的进行分析. 源码分析 Bootstrap的load方法是加载tomcat的server.xml的入口,load方法实际通过反射调用了Catalina的load方法,见代码清单1. 代码清单1 /** * Load daemon. */ private void load(String[] arguments) throws Exceptio

Tomcat源码分析——server.xml文件的加载与解析

前言 作为Java程序员,对于tomcat的server.xml想必都不陌生.本文基于Tomcat7.0的Java源码,对server.xml文件是如何加载和解析进行分析. 加载过程分析 Bootstrap的load方法用于加载tomcat的server.xml,实际是通过反射调用Catalina的load方法,代码如下: /** * Load daemon. */ private void load(String[] arguments) throws Exception { // Call

java.io.FileNotFoundException: /opt/apache-tomcat-7.0.57/conf/server.xml (权限不够)

1 错误描述 [email protected]:~$ cd /opt/apache-tomcat-7.0.57 [email protected]:/opt/apache-tomcat-7.0.57$ bin/startup.sh Using CATALINA_BASE: /opt/apache-tomcat-7.0.57 Using CATALINA_HOME: /opt/apache-tomcat-7.0.57 Using CATALINA_TMPDIR: /opt/apache-tomc

tomcat部署多项目server.xml配置

首先,我们以windows为例,其他系统类似. 第一种情况:多项目使用同一域名,我们以两个项目为例. 为了配置方便, 我们先把这两个项目的war包放到tomcat的webapps目录下. 我们现在看一下配置: [html] view plain copy <?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under

Tomcat/conf/server.xml文件中docBase和path的说明

Tomcat的项目部署方式有以下三种: 1.直接把项目复制到Tomcat安装目录的webapps目录中,这是最简单的一种Tomcat项目部署的方法.2.在tomcat安装目录中有一个conf文件夹,打开此文件夹,其中包含配置文件server.xml,打开配置文件,并在<host>和</host>之间插入如下语句.<Context path="/xxxxxx" docBase="xxxxxx" debug="0" pr

Tomcat中server.xml文件的配置

server.xml文件当中可配置如下信息: 1)配置端口号(如果是正式网站,要把8080改成80)<Connector executor="tomcatThreadPool" port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> 2)配置域名(网站的域名)---把localhost改成如

Linux配置多个Tomcat同时运行

(1)环境变量 修改/etc/profile文件. 添加一组Java环境变量(如果已经有了就不用再添加),和两组CATALINA环境变量 vim /etc/profile #java export JAVA_HOME=/opt/jdk1.8.0_66 export PATH=${JAVA_HOME}/bin:${JAVA_HOME}/jre/bin:${PATH} export CLASSPATH=.:${JAVA_HOME}/lib:${JAVA_HOME}/jre/lib #第一个Tomca

Tomcat记录-tomcat常用配置详解和优化方法

常用配置详解 1 目录结构 /bin:脚本文件目录. /common/lib:存放所有web项目都可以访问的公共jar包(使用Common类加载器加载). /conf:存放配置文件,最重要的是server.xml. /logs:存放日志文件. /server/webapps:来管理Tomcat-web服务用的.仅对TOMCAT可见,对所有的WEB APP都不可见(使用Catalina类加载器加载). /shared/lib:仅对所有WEB APP可见,对TOMCAT不可见(使用Shared类加载

Tomcat下conf下server.xml的文件配置信息

Tomcat下conf下server.xml的文件配置信息,基本上不用做任何修改就可以使用,修改的地方就是host区域的一些配置,此文件设置端口为80. 注意:Tomcat配置文件中(即server.xml文件)不能出现中文,否则服务是无法启动的. [xhtml] view plaincopy <!-- Server中的port监听关闭tomcat的请求,shutdown指定向端口发送的命令串--> <Server port="8005" shutdown="