install tomcat on ubuntu (for hudson)

###make sure that java-6-sun is installed
dpkg –get-selections | grep sun-java

###download an unpack the latest tomcat binary release
cd /tmp
wget http://apache.lauf-forum.at//tomcat/tomcat-7/v7.0.2-beta/bin/apache-tomcat-7.0.2.tar.gz
tar xvzf apache-tomcat-7.0.2.tar.gz
rm apache-tomcat-7.0.2.tar.gz
mv apache-tomcat-7.0.2 /usr/share/tomcat

###create user and group ‘hudson’ if not existing already
groupadd hudson
useradd -g hudson -d /home/hudson tomcat
passwd hudson

###create hudson start script

vi /etc/init.d/tomcat

###insert the following content into this newly created file:

#################################################################
# Tomcat auto-start
#
# description: Auto-starts tomcat
# processname: tomcat
# pidfile: /var/run/tomcat.pid

export JAVA_HOME=/usr/lib/jvm/java-6-sun
export CATALINA_OPTS=”-DHUDSON_HOME=/var/lib/hudson/ -Xmx512m”

case $1 in
start)
su hudson /usr/share/tomcat/bin/startup.sh
;;
stop)
su hudson /usr/share/tomcat/bin/shutdown.sh
;;
restart)
su hudson /usr/share/tomcat/bin/shutdown.sh
su hudson /usr/share/tomcat/bin/startup.sh
;;
esac
exit 0

#################################################################

###stop editing 😉

###make start script executable
sudo chmod 755 /etc/init.d/tomcat

###remove Winstone Hudson from startup
update-rc.d -f hudson remove

###add the newly installed tomcat to auto start
update-rc.d tomcat start 20 2 3 4 5 . stop 80 0 1 6 .

###deploy hudson
###
###to deploy hudson as the only application in your tomcat,
###just remove the webapps/ROOT folder and deploy hudson.war
###as ROOT.war

Posted in

Permalink