This example demonstrates how to install Tomcat as a service on Ubuntu using the *.tar.gz releases of both Tomcat as well as Java.
/opt/
/opt/jre1.Xxxx/
cd /opt; sudo ln -s jre1.Xxxxx java
sudo vim /etc/environment
JAVA_HOME="/opt/java"
sudo useradd -r tomcat
/opt/
/opt/apache-tomcat-XXXX
sudo chown -R tomcat ./*
sudo chgrp -R tomcat ./*
CATALINA_HOME
environment variable:sudo vim /etc/environment
CATALINA_HOME="/opt/tomcat"
tomcat-users.xml
sudo vim /opt/tomcat/conf/tomcat-users.xml
<user username="admin" password="adminpw" roles="manager-gui">
<tomcat-users>
... </tomcat-users>
tagsAdd a script in /etc/init.d called tomcat and make it executable. The content of the script can look something like:
RETVAL=$?
CATALINA_HOME="/opt/tomcat"
case "$1" in
start)
if [ -f $CATALINA_HOME/bin/startup.sh ];
then
echo $"Starting Tomcat"
sudo -u tomcat $CATALINA_HOME/bin/startup.sh
fi
;;
stop)
if [ -f $CATALINA_HOME/bin/shutdown.sh ];
then
echo $"Stopping Tomcat"
sudo -u tomcat $CATALINA_HOME/bin/shutdown.sh
fi
;;
*)
echo $"Usage: $0 {start|stop}"
exit 1
;;
esac
exit $RETVAL
To make it start on boot, run: sudo update-rc.d tomcat defaults
You can also add a bash line to /etc/rc.local for example service tomcat start
Edit the file $CATALINA_HOME/bin/setenv.sh
and add the properties in here, for example: CLASSPATH=/additional/class/directories