Install Apache Tomcat 5.5 on Ubuntu 8.04 Hardy Heron

To install and run Tomcat on Ubuntu (8.04 over here) the following packages should be installed from synaptic :

1. tomcat5.5
2. tomcat5.5-webapps
3. sun-java6-jdk

They can be installed from command line using the command sudo apt-get

After synaptic finishes installing them open /etc/default/tomcat5.5 and edit it as follows :

Find :
#JAVA_HOME=/usr/lib/jvm/java-6-sun

Change : Remove the # so that it is uncommented.
JAVA_HOME=/usr/lib/jvm/java-6-sun

It points to the java home which can be java-6-sun or any other java .

Then restart tomcat5.5 from command line like this :

enlightened@enlightened-desktop:~$ sudo /etc/init.d/tomcat5.5 restart
* Stopping Tomcat servlet engine tomcat5.5 [ OK ]
* Starting Tomcat servlet engine tomcat5.5 [ OK ]

Now open in your browser the url :

http://localhost:8180/

And the welcome page of Apache Tomcat should appear.

The file
/usr/share/tomcat5.5/conf/tomcat-users.xml
has the default username and password listed which is username : tomcat and password : tomcat.

On the tomcat welcome page Tomcat Administration link is on the left :
http://localhost:8180/admin

Opening this page might show the error message :
HTTP Status 403 – Access to the requested resource has been denied

To fix the above issue open the file
/usr/share/tomcat5.5/conf/tomcat-users.xml

sudo gedit /usr/share/tomcat5.5/conf/tomcat-users.xml

and add a role called admin and user called admin with that role :

<role rolename=”admin”/>
<user username=”admin” password=”tomcat” roles=”tomcat,admin”/>

Restart tomcat from command line as shown above.

Now log in to the administration panel :
http://localhost:8180/admin

with username : admin and password : tomcat.
The login should take you to the admin panel without any error.

To the left is another link of Tomcat Manager :
http://localhost:8180/manager/html

which might still show the error of Access denied.

To fix this issue simply login to the admin panel and create a role called manager (if it doesnt exist) and assign this role to a non-admin user like tomcat or create a new user.

Then log in to the Tomcat Manager page and it should open fine without any errors.

Now /usr/share/tomcat-webapps is the folder that contains the jsp files/webapps which are accessible from localhost:8180 url.

To change the directory of webapps to say one in /home/username/tomcat

Open : /usr/share/tomcat5.5-webapps/ROOT.xml

Look for :
Context path=”/” docBase=”/usr/share/tomcat5.5-webapps/ROOT”
and change the docBase value to the folder where the tomcat webapps would be.
e.g.

Context path=”/” docBase=”/home/enlightened/tomcat”
or
Context path=”/” docBase=”/var/www/tomcat”

Save the file and restart tomcat.

One more thing you can do is copy the contents of the /usr/share/tomcat5.5-webapps/ROOT directory to this new directory and then open the url localhost:8180 to check that everything is working fine. The admin and manager pages on the left and the jsp examples also should all open fine as previously.

Popularity: 12% [?]

Leave a Reply