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

Related posts

28 thoughts on “How to install Tomcat 6 on Ubuntu 9.04 (Jaunty)

  1. 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. There is a minor typo in your Howto:

    It says:

    Should say:

    Great howto anyways, cheers

  3. I can’t open


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

    Help please. Thanks!

  4. Missed some due to the chars.

    Should be:

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

  5. 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.

  6. 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!

  7. 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.

  8. 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.

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

  10. @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

  11. 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).

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

  13. @scoot
    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.

  14. Hi,
    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 comment

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