首页 > 其他分享 >tomcat学习一:tomcat 目录及配置文件学习 server.xml 等

tomcat学习一:tomcat 目录及配置文件学习 server.xml 等

时间:2022-12-30 18:37:39浏览次数:38  
标签:xml tomcat 配置文件 -- 2016 alsc staff


文章目录

  • ​​前言​​
  • ​​一、目录结构及作用​​
  • ​​二、conf配置文件​​
  • ​​1、概述​​
  • ​​a、context.xml​​
  • ​​b、web.xml​​
  • ​​c、server.xml​​
  • ​​d、tomcat-users.xml​​
  • ​​1、配置文件: server.xml​​
  • ​​a、全部内容​​
  • ​​b、全部内容(去掉注释)​​
  • ​​c、标签分析​​
  • ​​3、配置文件:待写​​

前言

  1. 很久没有用到tomcat了,因老师需求是springboot项目,所以打算系统整理一下,有些地方也借鉴了其他博文,在此表示感谢。
  2. tomcat版本:​​apache-tomcat-7.0.70​

一、目录结构及作用

查看目录:

(base) C02ZT6HWLVDL:apache-tomcat-7.0.70 alsc$ ls -l
total 176
-rw-r--r--@ 1 alsc staff 56846 Jun 16 2016 LICENSE
-rw-r--r--@ 1 alsc staff 1239 Jun 16 2016 NOTICE
-rw-r--r--@ 1 alsc staff 8965 Jun 16 2016 RELEASE-NOTES
-rw-r--r--@ 1 alsc staff 16195 Jun 16 2016 RUNNING.txt
drwxr-xr-x@ 25 alsc staff 800 Nov 2 17:11 bin
drwxr-xr-x@ 10 alsc staff 320 Nov 7 17:17 conf
drwxr-xr-x@ 23 alsc staff 736 Jun 16 2016 lib
drwxr-xr-x@ 19 alsc staff 608 Nov 8 12:54 logs
drwxr-xr-x@ 3 alsc staff 96 Jun 16 2016 temp
drwxr-xr-x@ 7 alsc staff 224 Jun 16 2016 webapps
drwxr-xr-x@ 3 alsc staff 96 Nov 2 17:12 work
(base) C02ZT6HWLVDL:apache-tomcat-7.0.70 alsc$

tomcat学习一:tomcat 目录及配置文件学习 server.xml 等_学习

  1. bin :脚本文件目录。
  2. conf:存放配置文件,最重要的是server.xml。
  3. lib :仅对所有WEB APP可见,对TOMCAT不可见(使用Shared类加载器加载)。
  4. logs:存放日志文件。
  5. temp:Tomcat运行时候存放临时文件用的。
  6. webapps:web应用发布目录。
  7. work:Tomcat把各种由jsp生成的servlet文件放在这个目录下。删除后,启动时会自动创建。

懒得画图,从网上找了一张图,很直观:

tomcat学习一:tomcat 目录及配置文件学习 server.xml 等_tomcat_02

二、conf配置文件

1、概述

  • 查看:
(base) C02ZT6HWLVDL:conf alsc$ ls -l
total 408
drwxr-xr-x 3 alsc staff 96 Nov 2 17:12 Catalina
-rw-------@ 1 alsc staff 12257 Jun 16 2016 catalina.policy
-rw-------@ 1 alsc staff 6322 Jun 16 2016 catalina.properties
-rw-------@ 1 alsc staff 1394 Jun 16 2016 context.xml
-rw-------@ 1 alsc staff 3288 Jun 16 2016 logging.properties
-rw-------@ 1 alsc staff 1759 Nov 7 17:17 server.xml
-rw-------@ 1 alsc staff 1950 Jun 16 2016 tomcat-users.xml
-rw-------@ 1 alsc staff 168099 Jun 16 2016 web.xml
  • Tomcat 的配置文件由4个 xml 文件构成,​​context.xml​​​、​​server.xml​​​、​​tomcat-users.xml​​​、​​web.xml​​。

a、context.xml

Context.xml 是 Tomcat 公用的环境配置,tomcat 服务器会定时去扫描这个文件。一旦发现文件被修改(时间戳改变了),就会自动重新加载这个文件,而不需要重启服务器。

服务一旦启动,在去修改server.xml,就得需要重新加载配置文件,或者重新启动服务来加载文件。 而context.xml的优势是无需重启。 所以我们一般会在这个文件中独立配置。

b、web.xml

Web应用程序描述文件,都是关于是Web应用程序的配置文件。所有Web应用的 web.xml 文件的父文件。

c、server.xml

server.xml是对tomcat的设置,可以设置端口号,添加虚拟机这些的,是对服务器的设置

d、tomcat-users.xml

Tomcat Manager是Tomcat自带的、用于对Tomcat自身以及部署在Tomcat上的应用进行管理的web应用。Tomcat是Java领域使用最广泛的服务器之一,因此Tomcat Manager也成为了使用非常普遍的功能应用。
Tomcat Manager的用户配置是在Tomcat安装目录/conf/tomcat-users.xml文件中进行管理的

1、配置文件: server.xml

a、全部内容

直接复制过来的

<?xml version='1.0' encoding='utf-8'?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Note: A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" at this level.
Documentation at /docs/config/server.html
-->
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<!-- Security listener. Documentation at /docs/config/listeners.html
<Listener className="org.apache.catalina.security.SecurityListener" />
-->
<!--APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
<Listener className="org.apache.catalina.core.JasperListener" />
<!-- Prevent memory leaks due to use of particular java/javax APIs-->
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

<!-- Global JNDI resources
Documentation at /docs/jndi-resources-howto.html
-->
<GlobalNamingResources>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>

<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" Note: A "Service" is not itself a "Container",
so you may not define subcomponents such as "Valves" at this level.
Documentation at /docs/config/service.html
-->
<Service name="Catalina">

<!--The connectors can use a shared executor, you can define one or more named thread pools-->
<!--
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="150" minSpareThreads="4"/>
-->


<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
Java AJP Connector: /docs/config/ajp.html
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL HTTP/1.1 Connector on port 8080
-->
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
-->
<!-- Define a SSL HTTP/1.1 Connector on port 8443
This connector uses the BIO implementation that requires the JSSE
style configuration. When using the APR/native implementation, the
OpenSSL style configuration is required as described in the APR/native
documentation -->
<!--
<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
-->

<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host).
Documentation at /docs/config/engine.html -->

<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
-->
<Engine name="Catalina" defaultHost="localhost">

<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->

<!-- Use the LockOutRealm to prevent attempts to guess user passwords
via a brute-force attack -->
<Realm className="org.apache.catalina.realm.LockOutRealm">
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>

<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">

<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->

<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />

</Host>
</Engine>
</Service>
</Server>

b、全部内容(去掉注释)

<?xml version='1.0' encoding='utf-8'?>

<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JasperListener" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>

<Service name="Catalina">
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>

<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
</Server>

c、标签分析

​​Tomcat Server.xml配置详解

3、配置文件:待写


标签:xml,tomcat,配置文件,--,2016,alsc,staff
From: https://blog.51cto.com/u_15926676/5981134

相关文章

  • nginx学习:配置文件详解,负载均衡三种算法学习,上接nginx实操篇
    文章目录​​前言​​​​一、对上一篇博文的分析​​​​二、配置文件分析​​​​1.nginx官方网址(很详细)​​​​2、配置文件(全)​​​​3、配置文件(去掉注释)​​​​4、......
  • tomcat报错总结C:\Program Files\Apache Software Foundation\Tomcat 8.5\logs\c
    错误问题一java.util.logging.ErrorManager:4java.io.FileNotFoundException:C:\ProgramFiles\ApacheSoftwareFoundation\Tomcat8.5\logs\catalina.2018-11-07.log(......
  • Tomcat WEB服务器日志切割
    cronolog简介cronolog是一个简单的过滤程序,读取日志文件条目从标准输入和输出的每个条目并写入指定的日志文件的文件名模板和当前的日期和时间。当扩展文件名的变化,目前的......
  • Tomcat 8.x基于Redis Session会话保持
    什么是Redis?Redis是一个开源的使用ANSIC语言编写、支持网络、可基于内存亦可持久化的日志型、Key-Value数据库,并提供多种语言的API。一、与其他用户状态保存方案比较一般开......
  • Spring MVC的web.xml配置详解
    SpringMVC是创建javaweb项目时比较常用的框架,其中web.xml配置文件是更不可少的,那么首先先了解javaweb中的web.xml文件。一、认识web.xml文件1、web.xml的作用首先java......
  • Java 将HTML转为XML
    本文介绍如何通过Java后端程序代码来展示如何将html转为XML。此功能通过采用WordAPI-​​FreeSpire.DocforJava​​提供的Document.saveToFile()方法来实现;该方法支持的......
  • python之xml基本操作
    1.概述XML(ExtensibleMarkupLanguage)中文译为可扩展标记语言,它是一种简单、灵活、易扩展的文本格式,它主要关注数据内容,常用来传送、存储数据。当通过XML来传送数据......
  • 安装 PHP No package 'libxml-2.0' found
    centos7编译安装php7遇到的问题:./configure配置遇到的Nopackage‘libxml-2.0‘found缺失libxml2.0库,解决方法:yum-yinstalllibxml2yum-yinstalllibxml2-devel......
  • Selenium40-配置文件
    配置文件配置文件是记录可能会有改动的配置项目的文件提取配置文件的目的是为了使代码更加灵活,对可能经常变动的地方修改更加方便,所以使用配置文件读取配置文件的应......
  • 用Python解析XML的几种常见方法的介绍
    一、简介XML(eXtensibleMarkupLanguage)指可扩展标记语言,被设计用来传输和存储数据,已经日趋成为当前许多新生技术的核心,在不同的领域都有着不同的应用。它是web发展到一定......