How to configure Tomcat to run not as root
PostPosted:Mon Jul 07, 2014 7:03 am
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:
Regards,
Tio
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:
- Adding user openkm with Code: Select all
$ sudo adduser openkm - Create tomcat in /etc/init.d with Code: Select all
$ sudo nano /etc/init.d/tomcat - 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 - Make it executeable with Code: Select all
$ sudo chmod 755 /etc/init.d/tomcat - Update the run levels with Code: Select all
$ sudo update-rc.d tomcat defaults - Run service with Code: Select all
$ sudo service tomcat start - 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
Regards,
Tio