Chiranga Alwis
Chiranga Alwis

Reputation: 1101

Configuring custom Tomcat configuration folder

In Apache Tomcat the traditional home of all configuration files is the ${catalina.home/base}/conf folder.

Can we configure a custom folder within our file system (may be outside the CATALINA_HOME/BASE) to act as the configuration home of Tomcat? If yes, how can we do that?

Upvotes: 4

Views: 4021

Answers (1)

geert3
geert3

Reputation: 7321

You cannot split off the conf directory. Usually what you do - and what's suggested by Tomcat documentation - is you have a single "binary" installation of tomcat, pointed to by CATALINA_HOME, and one or possibly several "personal" instances each having a conf, webapps and so on are. This would be pointed to by CATALINA_BASE. So to answer your question: set an environment variable CATALINA_BASE underneath which you can have your "external" configuration directory.

For completeness, here is the relevant info from the file RUNNING.txt under the Tomcat installation:

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.

Upvotes: 4

Related Questions