Pivotal Knowledge Base

Follow

VMware: Running Apache Tomcat instance as a daemon on Linux

 

Purpose

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. 

Resolution

To run a Tomcat instance as a daemon on Linux:
  1. 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.


  2. 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.

For more information, see http://tomcat.apache.org/tomcat-6.0-doc/setup.html#Unix_daemon.

Additional Information

 

©VMware 2013

Comments

Powered by Zendesk