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

Install tomcat 6 in ubuntu 9.04

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

Start tomcat server

1
sudo /etc/init.d/tomcat6 start

Stop tomcat server

1
sudo /etc/init.d/tomcat6 stop

Restart tomcat server

1
sudo /etc/init.d/tomcat6 restart

Get tomcat server status

1
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

1
2
3
4
5
<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 the 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

1
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

1
sudo /etc/init.d/tomcat6 restart
Share this post

7 Comments

  1. GEM Parker

    this help me a lot
    can you provide me a detail explaination for the servelt,

    February 13, 2011
  2. Daniel

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

    it should be tomcat-users.xml
    (further down your wrote it correctly)

    thx for the tutorial.

    June 9, 2011
  3. Sethathi

    Thank a lot :)

    August 17, 2011
  4. your documents all good small modification user’s enabled can u change it

    </tomcat-users

    September 26, 2011
  5. sathish
    September 26, 2011
  6. Nag

    Dear Team,

    I installed the Tomcat and started sever but it is asking Username and Password ,can any tell me the username and password ?

    October 14, 2011
  7. kahoots

    Nag,

    You have to edit the /etc/tomcat6/tomcat-users.xml file.

    This will work:

    username/password = tomcat/tocmat

    November 7, 2011

Leave a Reply