If you're new here, you may want to subscribe to my RSS feed and if you have questions related to your ubuntu system post question to our forums. Thanks for visiting!
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 http://simple.souther.us/SimpleServlet.war
* 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 http://simple.souther.us/SimpleServlet.war 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







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
There is a minor typo in your Howto:
It says:
/etc/tomcat6/tomcat-user.xml
Should say:
/etc/tomcat6/tomcat-users.xml
Great howto anyways, cheers
Thanks for your comment i have updated the main article
I can’t open
/etc/tomcat6/tomcat-users.xml
error message says:
“You do not have the permissions necessary to open the file.”
Help please. Thanks!
You need to use sudo.
$ sudo /etc/tomcat6/tomcat-users.xml
and also it should be
Missed some due to the chars.
Should be:
user USERname=”admin” password=”secret_password” roles=”manager,admin”/
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.
You probably forgot to remove the XML comment markup from around the users and roles.
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!
Rahul, have you tried: sudo nano /etc/tomcat6/tomcat-users.xml
thanks for the article, it helps me!
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.
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.
Sorry my bad, typeo in xml
excellent article
good job
thanks!
Spectacular guide! I’m completely new to Tomcat, and this got me up and running immediately. Thanks for the help.
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/