Search This Blog

Monday, October 22, 2012

Configuring administration on Tomcat 7


In a previous blog (http://opendesignarch.blogspot.ca/2012/10/how-to-install-tomcat-7-on-ubuntu-1204.html), I walked through the steps of installing Tomcat 7 on Ubuntu. In this post, I would like to enable administrator access to allow deployment of webapps or Web Archive (.war files). Lets go through the steps.

When you access the default Tomcat 7 Administration page on http://localhost:8080/manager  or similar, you will see a username password prompt. Cancelling it you will see a screen like below.


As indicated, we need to install tomcat7-admin page to access the manager webapp. As shown in the last step of our previous post, this is done as following...

We will also need to obtain the tomcat7-admin package by entering the following

> sudo apt-get install tomcat7-admin


If we now do a search for all folders in /usr/share prefixed with tomcat we should see the following

tomcat7
tomcat7-admin
tomcat7-root

> ls /usr/share/tomcat*



Also, if we browse the folder /var/lib/tomcat7, we should see the faimilar structure from previous generation Tomcat instances

> ls /var/lib/tomcat*



To configure administration, we need to enable the manager. Clicking on the link for manager in the Tomcat home page (http://localhost:8080/manager), will show the following screen with the steps to be followed.


As indicated, the conf folder is installed under /var/lib/tomcat7. Lets go there and open the tomcat-users.xml file for editing as follows

> cd /var/lib/tomcat7/conf
> ls
> sudo gedit tomcat-users.xml




This should open the file for editing. Add the following lines

<role rolename="manager-gui"/>
<user username="manager" password="manager" roles="manager-gui"/>



Save the file and exit

Next, restart the tomcat7 service from the command line as follows.

> sudo /etc/init.d/tomcat7 restart

The service should stop and restart.


Next access the page http://localhost:8080/manager

You will see a prompt to enter the username and password for the manager. Go ahead and enter the username/ password we just created. In my case it was manager/ manager.


Voila, we can see the Tomcat administration screen as shown below.


There you go!

No comments: