tomcat - 配置自定义 Tomcat 配置文件夹

标签 tomcat

在 Apache Tomcat 中,所有配置文件的传统位置是 ${catalina.home/base}/conf 文件夹。

我们可以在我们的文件系统中配置一个自定义文件夹(可能在 CATALINA_HOME/BASE 之外)作为 Tomcat 的配置主目录吗?如果是,我们该怎么做?

最佳答案

您不能拆分conf 目录。通常你所做的 - 以及 Tomcat 文档的建议 - 你有一个 tomcat 的“二进制”安装,由 CATALINA_HOME 指向,以及一个或可能几个“个人”实例,每个实例都有一个 confwebapps等都是。这将由 CATALINA_BASE 指向。因此,回答您的问题:设置一个环境变量 CATALINA_BASE,在该变量下您可以拥有“外部”配置目录。

为了完整起见,以下是 Tomcat 安装下的文件 RUNNING.txt 中的相关信息:

In many circumstances, it is desirable to have a single copy of a Tomcat binary distribution shared among multiple users on the same server. To make this possible, you can set the $CATALINA_BASE environment variable to the directory that contains the files for your 'personal' Tomcat instance.

When you use $CATALINA_BASE, Tomcat will calculate all relative references for files in the following directories based on the value of $CATALINA_BASE instead of $CATALINA_HOME:

  • bin - Only setenv.sh (*nix), setenv.bat (windows) and tomcat-juli.jar

  • conf - Server configuration files (including server.xml)

  • logs - Log and output files

  • webapps - Automatically loaded web applications

  • work - Temporary working directories for web applications

  • temp - Directory used by the JVM for temporary files (java.io.tmpdir)

Note that by default Tomcat will first try to load classes and JARs from $CATALINA_BASE/lib and then $CATALINA_HOME/lib. You can place instance specific JARs and classes (eg JDBC drivers) in $CATALINA_BASE/lib whilst keeping the standard Tomcat JARs in $CATALINA_HOME/lib.

If you do not set $CATALINA_BASE, $CATALINA_BASE will default to the same value as $CATALINA_HOME, which means that the same directory is used for all relative path resolutions.

关于tomcat - 配置自定义 Tomcat 配置文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35862427/

相关文章:

javascript - 为 windows.popup 传递发布数据

java - Tomcat 8 正在运行但拒绝连接

xml - 在 JSP 文件中导入带有 JSTL 核心的 XML 文件时,请求的资源不可用

javascript - 将 json 从 js 传递到 java 的 url 问题

java - 没有数据库web思想的持久化

java - eclipse中tomcat项目的目录结构

http - Varnish 不 gzip html 页面

java - 当我将 spring-boot war 部署到 tomcat 并启动 tomcat 时,我看到了这个错误消息

scala - 如何在 Tomcat 上部署 Scala/akka 应用程序?

spring - 尝试使用 Postgres、Tomcat、Hibernate 部署 Spring Boot 应用程序,但连接被拒绝