Running Apache Tomcat instance as a daemon on Linux
searchcancel
Running Apache Tomcat instance as a daemon on Linux
book
Article ID: 337052
calendar_today
Updated On: 08-21-2024
Products
VMwareSupport Only for Apache Tomcat
Issue/Introduction
This article provides information on running an Apache Tomcat instance as a daemon on Linux via JSVC to perform some root privileged operation such as binding Tomcat to a port < 1024, and switching back to a non-privileged user status.
Symptoms:
Environment
Apache Tomcat 5.5
Resolution
To run a Tomcat instance as a daemon on Linux:
Extract the included commons-daemon source and build the jsvc tool for daemonizing Tomcat.
> $CATALINA_HOME/bin > tar xvfz commons-daemon-native.tar.gz > cd commons-daemon-1.0.x-native-src/unix > ./configure > make > cp jsvc ../../
Note: You need a compiler, make and Java to build JSVC binary. If you do not have Java path environment (JAVA_HOME) predefined , you can run ./configure --with-java=/specify/path/to/java.
Copy sample tomcat.sh (see Attachments) to $CATALINA_BASE/bin path, and use it to run to as a daemon. Make sure to setup the setenv.sh and the following variables in tomcat.sh for your deployment environment:
# Define the user we want to run Tomcat as TOMCAT_USER="john"
# Enabling or disabling the security manager in Tomcat? # By default the security mechanism is disabled. Options: enable or disable SECURITY="disable"
Note: You can copy the setenv.sh (see Attachments) to $CATALINA_BASE/bin path or create your own setenv.sh that tomcat.sh script will use to source Tomcat and Java environment variables.
You can also use the sample tomcat5.sh or tomcat7.sh template scripts in commons-daemon-1.0.x-native-src/unix/sample folder or create your own script to run Tomcat.