Installing and configuring Tomcat on Ubuntu

This documentation owes its credits to the Ubuntu Community (Docs) and the book: Java-The Complete Reference by Herbert Schieldt where I learnt the basics of Java and Servlets. Let’s begin.

Before starting you need the Java Development Kit (JDK) and not Java Runtime Environment (JRE). Download it from as a .bin file and install it on your system or use the command:

sudo apt-get install sun-java5-jdk

Then set the Java Runtime variable

$ export JAVA_HOME=”Your java path”
$ export PATH=$PATH:$JAVA_HOME /bin

e.g. on Dapper

$ export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun-

Now use the following command to install Tomcat

$ sudo aptitude install tomcat5 tomcat5-admin tomcat5-webapps

Now its Done….

To Start, Stop and Restart the server

$ sudo /etc/init.d/tomcat5 start
$ sudo /etc/init.d/tomcat5 stop
$ sudo /etc/init.d/tomcat5 restart

You can access the root directory via port 8180 and the server listens to the address So type in your web browser to access the server.

A word of precaution: It’s better to avoid running Tomcat as root.
There are many other setting within Tomcat, I think the user should better try them out themselves. Some are:
1) Making Tomcat to run on port 80.
2) Turning off Directory Listings like Index Manager.
3) Check out the Tomcat configuration file and try out something of your own. Only precaution required is that you should not be logged in as root.

11 thoughts on “Installing and configuring Tomcat on Ubuntu

  1. Nice walkthrough. Most helpful. Just a thought, perhaps the addition of where $TOMCAT_HOME is installed would be helpful…

  2. I was wondering if I could uninstall Tomcat from my Ubuntu. Can you do it? Could you please email the solution to me? I have and older version I want to get rid of. Thanks.

  3. Just happened to take a look into the /etc/init.d/tomcat5.5 script and that already does the setting of the JAVA_HOME, TOMCAT_USER etc variables. So as long as you start your tomcat server with the /etc/init.d/tomcat5.5 script then all that work is done for you.

  4. I didnt get what you meant by Installing manually? You want to compile it from source?
    Please do the same if you want the newest version of any software. Again you can find all latest versions of most software in *testing* repo of ubuntu.

    1. I installed tomcat server through synaptic package manager but i dont know how to set paths and how to use tomcat server.
      plz suggest me to how to execute my servlet and jsp applications on ubuntu
      waiting for ur reply

      1. Setting the paths is given in the post itself.

        plz suggest me to how to execute my servlet and jsp applications on ubuntu

        I am assuming you know how to program using servelt and jsp? How you did before?

  5. hi manish,

    I see a fail status when trying to start tomcat using /etc/init.d/tomcat6 start

    bezgoan@bezgoan-E6221:/etc/init.d$ sudo ./tomcat6 start
    * Starting Tomcat servlet engine tomcat6 [fail]

    I have set JAVA_HOME.

    Can you suggest where to look for the failure log ?


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s