How to install Tomcat 6 on Ubuntu 9.04 (Jaunty)

Sponsored Link
Apache Tomcat is a free and open source software implementation for JavaServlets, providing support for Java Server Pages (JSP). Many popular web-based applications use servlets. You may choose to run Tomcat with either Sun's Java implementation or the OpenJDK implementation of Java.

Because Tomcat version 6 was included in Ubuntu 9.04, installing a working Tomcat server is reasonably straightforward. However, before we can start installing Tomcat itself, we must first install Java.

First Install Sun Java in ubuntu 9.04 using this tutorial

Install tomcat 6 in ubuntu 9.04

sudo apt-get install tomcat6 tomcat6-admin tomcat6-common tomcat6-user tomcat6-docs tomcat6-examples

This command downloads and install the following packages

tomcat6 : Servlet and JSP engine

tomcat6-admin : Admin web applications

tomcat6-common : Common files

tomcat6-user : Tools to create user instances

tomcat6-docs : Example web applications

tomcat6-examples : Example web applications

To start, stop,  restart and get the server status

Start tomcat server

sudo /etc/init.d/tomcat6 start

Stop tomcat server

sudo /etc/init.d/tomcat6 stop

Restart tomcat server

sudo /etc/init.d/tomcat6 restart

Get tomcat server status

sudo /etc/init.d/tomcat6 status

After installation type http://localhost:8080  or http://serverip:8080/examples/servlets/ in your browser.Now you should see tomcat welcome page

* To enable admin web based features add the following lines to your /etc/tomcat6/tomcat-user.xml

<role rolename="manager"/>
<role rolename="admin"/>
<user name="admin" password="secret_password" roles="manager,admin"/>

* you should be able to see your manage page here http://your_ip_goes_here:8080/manager/html

* log in with the name and password you just set in /etc/tomcat6/tomcat-users.xml

* ls /var/lib/tomcat6 directory.

* you should see these directories conf, logs, webapps, work

* webapps is where your servlets will go ( or at least a xml file that points to them )

* as a test download this war file

* then use the tomcat management page and select war file to deploy ( in teh deploy section) to upload this file to your server

* optionally just wget directly to the webapps folder

* tomcat should recognize the war file and expand it with everything you need

* browse to http://serverip:8080/SimpleServlet/

Change tomcat server to run on port 80

If you want to Change tomcat server to run on port 80 follow this procedure

You need to edit the /etc/tomcat6/server.xml file

nano /etc/tomcat6/server.xml

Now replace the part that says Connector port=”8080? with Connector port=”80?

Save and exit the file

Restart tomcat server with the following command

sudo /etc/init.d/tomcat6 restart

Sponsored Link

You may also like...

28 Responses

  1. Aaron says:

    Don’t forget “tasksel.” The following will install the Tomcat server, exactly as if you had selected it (configuration and all) from the menu using Ubuntu Server edition (great for installing it on K/Ubuntu desktop systems):

    sudo tasksel install tomcat-server

  2. Giacomo says:

    There is a minor typo in your Howto:

    It says:

    Should say:

    Great howto anyways, cheers

  3. admin says:

    Thanks for your comment i have updated the main article

  4. Ace says:

    I can’t open


    error message says:
    “You do not have the permissions necessary to open the file.”

    Help please. Thanks!

  5. radishr00t says:

    You need to use sudo.

    $ sudo /etc/tomcat6/tomcat-users.xml

    and also it should be

  6. radishr00t says:

    Missed some due to the chars.

    Should be:

    user USERname=”admin” password=”secret_password” roles=”manager,admin”/

  7. Jaime says:

    I modify as specified on your instruction for the tomecat-users.xml (fixed the user username= as well) but when i tried to login to the page it does not recognize the username admin and the password i set. kept coming to prompt username and password.. any clue? i am using firefox and also restarted the tomcat services dozen times.

  8. Frans says:

    You probably forgot to remove the XML comment markup from around the users and roles.

  9. Rahul says:

    Hi All,
    While I am changing the Username and Password in Tomcat6. It is saying that i don’t have permission to write that file. when I open /etc/tomcat6/tomcat-users.xml with sudo command. It is saying “Command not found”.
    Even I am not able to open tomcat-users.xml file. They is a cross mark at the top corner of the file.please help me I want to start Tomcat on ubuntu. So that I show my friends that everything happens on ubuntu!

  10. rizki says:

    Rahul, have you tried: sudo nano /etc/tomcat6/tomcat-users.xml

  11. Markus says:

    thanks for the article, it helps me!

  12. Narendra Sarkar says:

    I could see admin and management interface for the default tomcat instance. But, how to configure admin and management interface for tomcat user instance which is created by tomcat6-instance-create myinstance command. I don’t see management and admin interface for my user tomcat instance.

  13. david says:

    I have added the roles and user, after restarting tomcat I can’t even access http://localhost:8080/ it just keeps loading forever. commenting out all users and restarting tomcat makes tomcat available again, but then i can’t run the manager.

  14. david says:

    Sorry my bad, typeo in xml

  15. tormentor says:

    excellent article

    good job

  16. alan says:


  17. Chris says:

    Spectacular guide! I’m completely new to Tomcat, and this got me up and running immediately. Thanks for the help.

  18. Ivan says:

    I modified the server.xml file for the Connector as stated:

    Now replace the part that says Connector port=”8080″ with Connector port=”80″

    But now I just get the Apache default page at http://localhost and cannot access the examples, docs, etc. by browsing to http://localhost/examples/ or http://localhost/docs/

  19. Eddy says:

    @Ivan, I found that that didn’t not work for me either. What I found is to first undo the change you made in the server.xml file and do this…

    # install the iptables applications if they are not already there
    apt-get -y install iptables
    # tell iptables to forward incoming requests on port 80 to tomcat
    /sbin/iptables -t nat -I PREROUTING -p tcp –dport 80 -j REDIRECT –to-port 8080

    after I did this every thing worked great

    BTW thanks for this article, it was a great help

  20. Eddy says:


    you have to use sudo when running those commands

  21. scoot says:

    Suggestion for running on port 80 (tested on tomcat6 + ubuntu server 10.04 LTS).

    – edit server.xml as above to change to port 80
    – edit /etc/default/tomcat6 & change last line to:

    stop & restart server. Should then serve from port 80. Doesn’t need anything else (e.g. no iptables forwarding).

  22. Dark-Star1 says:

    Using CentOS and tomcat 5.5. that file doesn’t exist in the default folder for me.

  23. scoot says:

    Sorry to hear that. Afraid I’m not familiar with RPM-based distros including CentOS. From a quick googling jsvc seems to be the preferred approach to enabling port 80 on CentOS. Also a good description here:

    Good luck!

  24. Dark-Star1 says:

    Thanks for the reply but after a quick thought I have decided to go down the headache route of using iptables to forward to the tomcat port.

  25. Rais says:

    Thanks a lot !!! This helped a lot.

  26. mahesh says:

    thanks for helping this site

  27. sudhir singh says:

    type the following lines than you can open

    # gedit /etc/tomcat6/tomcat-users.xml

  28. pratim says:

    First of all, this is a great howto. I have installed tomcat6 and it is running fine. Could you help me to run a CGI script on it? I have put my cgi script in /var/lib/tomcat6/webapps/WEB-INF/cgi.
    The WEB-INF was not there, so also the cgi, i made these directories with sudo. Any sort of help will always be appreciated.

Leave a Reply

Your email address will not be published. Required fields are marked *