how to install Apache Tomcat 6 on Debian 5 (Lenny)

In my previous articles for installation and configuration of apache tomcat 6 I tried to focus on the configuration of this web server with other utilities like setting up apache tomcat with apache2, configuration of apache tomcat with virtual host and apcahe2. Today I like to share a very simple method that will show the steps of configuration of apache tomcat 6 on debian lenny with some java settings.

I hope that you have a working installation of Debian 5 (Lenny), and have enough knowledge to update and install new packages on the system. I also assume that you have a functional SSH connection and root access to your server. why would you look for  a functional SSH connection? because you can access the system using some connectivity software like putty to do the configurations.

Install a Java Implementation

You have to Make sure that your package repositories and installed programs are up to date by issuing the following commands:

apt-get update

apt-get upgrade –show-upgraded

I hope you are ready to install Sun Java with the following command (acknowledging the license terms): There might be other packages required to install sun-java6-jdk because of dependency but if have installed your Debian Lenny from a DVD and a complete installation I think you won’t be looking for any further package.

apt-get install sun-java6-jdk

If everything goes right and sun-java6-jdk has been installed correctly then you are ready to proceed with the Apache Tomcat install.

Installing Apache Tomcat

Download the latest version of Tomcat with the following command.

Latest version of apache tomcat 6

Confirm via MD5 hash that you’ve got an authentic package, use the under given command to check md5sum.

md5sum apache-tomcat-6.0.20.tar.gz

you can find updated versions from under given website;

< >

Extract the tomcat binary from the tarball with the following command:

tar -xzvf apache-tomcat-6.0.24.tar.gz

You have to move Tomcat directory to a permanent location by issuing this command:

mv apache-tomcat-6.0.24 /usr/local/tomcat

The scripts for controlling and interacting with Tomcat are located in the /usr/local/tomcat/bin directory.

Enable Tomcat to Start Automatically

Create a tomcat "init" file with the following content:

File Location: /etc/init.d/tomcat

# Tomcat auto-start

# description: Auto-starts tomcat

# processname: tomcat

# pidfile: /var/run/

export JAVA_HOME=/usr/lib/jvm/java-6-sun

case $1 in


sh /usr/local/tomcat/bin/



sh /usr/local/tomcat/bin/



sh /usr/local/tomcat/bin/

sh /usr/local/tomcat/bin/



exit 0

Make the script executable by issuing this command:

chmod +x /etc/init.d/tomcat

Finally, create symbolic links in the startup folders with these commands:

ln -s /etc/init.d/tomcat /etc/rc1.d/K99tomcat

ln -s /etc/init.d/tomcat /etc/rc2.d/S99tomcat

Tomcat should now be totally functional and should start automatically with the system. In the future, if you need to start, stop, or restart, you can use the following commands:

/etc/init.d/tomcat start

/etc/init.d/tomcat stop

/etc/init.d/tomcat restart

Just to reconfirm that your tomcat startup script is added in startup issue the command given as below.


if your system say that command not recognized no problem, you need to install a package the the under given command to install that package.

apt-get install dialog

Test and use Tomcat

You can test your Tomcat installation by pointing your browser to http://[your-ip-address]:8080/. By default, files are located at /usr/local/tomcat/webapps/.