• How to configure Tomcat to run not as root

  • OpenKM has many interesting features, but requires some configuration process to show its full potential.
OpenKM has many interesting features, but requires some configuration process to show its full potential.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #29184  by tiopourtu
 
Dear jllort,

I want to run tomcat not as root and start it up on boot. I have been searching in the forum and trial and error my self but no luck. I was using this instruction: http://wiki.openkm.com/index.php/Config ... vice_linux but it seems not working. Here's is my steps:
  1. Adding user openkm with
    Code: Select all
    $ sudo adduser openkm
  2. Create tomcat in /etc/init.d with
    Code: Select all
    $ sudo nano /etc/init.d/tomcat
  3. Change TOMCAT_HOME=/opt/openkm/tomcat
    Code: Select all
    #!/bin/sh
     
    ### BEGIN INIT INFO
    # Provides:          tomcat
    # Required-Start:    $remote_fs $syslog
    # Required-Stop:     $remote_fs $syslog
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # Short-Description: Start and stop Apache Tomcat
    # Description:       Enable Apache Tomcat service provided by daemon.
    ### END INIT INFO
     
    ECHO=/bin/echo
    TEST=/usr/bin/test
    TOMCAT_USER=openkm
    TOMCAT_HOME=/opt/openkm/tomcat
    TOMCAT_START_SCRIPT=$TOMCAT_HOME/bin/startup.sh
    TOMCAT_STOP_SCRIPT=$TOMCAT_HOME/bin/shutdown.sh
     
    $TEST -x $TOMCAT_START_SCRIPT || exit 0
    $TEST -x $TOMCAT_STOP_SCRIPT || exit 0
     
    start() {
        $ECHO -n "Starting Tomcat"
        su - $TOMCAT_USER -c "$TOMCAT_START_SCRIPT &"
        $ECHO "."
    }
     
    stop() {
        $ECHO -n "Stopping Tomcat"
        su - $TOMCAT_USER -c "$TOMCAT_STOP_SCRIPT 60 -force &"
        while [ "$(ps -fu $TOMCAT_USER | grep java | grep tomcat | wc -l)" -gt "0" ]; do
            sleep 5; $ECHO -n "."
        done
        $ECHO "."
    }
     
    case "$1" in
        start)
            start
            ;;
        stop)
            stop
            ;;
        restart)
            stop
            sleep 30
            start
            ;;
        *)
            $ECHO "Usage: tomcat {start|stop|restart}"
            exit 1
    esac
    exit 0
    
  4. Make it executeable with
    Code: Select all
    $ sudo chmod 755 /etc/init.d/tomcat
  5. Update the run levels with
    Code: Select all
    $ sudo update-rc.d tomcat defaults
  6. Run service with
    Code: Select all
    $ sudo service tomcat start
  7. Then I got this error message:
    Code: Select all
    Starting Tomcat.
    touch: cannot touch ‘/opt/openkm/tomcat/logs/catalina.out’: Permission denied
    /opt/openkm/tomcat/bin/catalina.sh: 385: /opt/openkm/tomcat/bin/catalina.sh: cannot create /opt/openkm/tomcat/logs/catalina.out: Permission denied
    
So what am I supposed to do ?

Regards,
Tio

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.