Category Archives: Tomcat

Install Tomcat under Debian

  1. Download Tomcat.
  2. Create /etc/init.d/tomcat as listed below and change properties in it as needed.
  3. Execute the following commands as root.
cd /opt
tar -xf apache-tomcat-7.0.25.tar.gz
ln -s apache-tomcat-7.0.25 tomcat
groupadd tomcat
useradd -g tomcat -d /opt/tomcat tomcat
usermod -G www-data tomcat
chown tomcat:tomcat /opt/apache-tomcat-7.0.25 -R
chmod +x /etc/init.d/tomcat
update-rc.d tomcat defaults

/etc/init.d/tomcat

#!/bin/sh
CATALINA_HOME=/opt/tomcat
export CATALINA_HOME
JAVA_HOME=/opt/jdk1.6.0_25
export JAVA_HOME
TOMCAT_OWNER=tomcat
export TOMCAT_OWNER
JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 
-server -Xms768m -Xmx768m
-XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m 
-XX:MaxPermSize=256m -XX:+DisableExplicitGC"
export JAVA_OPTS

start() {
  echo -n "Starting Tomcat:  "
  su $TOMCAT_OWNER -c $CATALINA_HOME/bin/startup.sh 
}
stop() {
   echo -n "Stopping Tomcat: "
   su $TOMCAT_OWNER -c $CATALINA_HOME/bin/shutdown.sh
}

case "$1" in
start)
   start
   ;;
stop)
   stop
   ;;
restart)
   stop
   start
   ;;
*)
   echo $"Usage: tomcat {start|stop|restart}"
   exit
esac