Install Apache Tomcat 7 on Linux

Introduction

Apache Tomcat is the most famous application server for web applications. In this article we are going to install Apache Tomcat 7 in gnu/linux rpm based systems. For the example we used Oracle Enterprise Linux 6.3 (OEL 6.3), but this guide can be used to install it in Fedora, CentOS or Red Hat Enterprise Linux (RHEL).

Download

Get the Apache Tomcat 7 package from Apache Foundation site [http://tomcat.apache.org/download-70.cgi]

Prerequisites

Check that you have JDK version 6 or 7 installed. You can follow this guide Installing Oracle JDK 64 bits rpm.bin on Linux

Install

Download the software using wget:

[zoomer@oel6 ~]$ wget http://apache.rediris.es/tomcat/tomcat-7/v7.0.34/bin/apache-tomcat-7.0.34.tar.gz
--2012-12-15 13:43:43--  http://apache.rediris.es/tomcat/tomcat-7/v7.0.34/bin/apache-tomcat-7.0.34.tar.gz
Resolving apache.rediris.es... 130.206.1.5
Connecting to apache.rediris.es|130.206.1.5|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7744774 (7,4M) [application/x-gzip]
Saving to: “apache-tomcat-7.0.34.tar.gz”
 
100%[======================================>] 7.744.774    426K/s   in 19s     
 
2012-12-15 13:44:03 (397 KB/s) - “apache-tomcat-7.0.34.tar.gz” saved [7744774/7744774]

Uncompress and untar the package

[zoomer@oel6 ~]$ tar zxvf apache-tomcat-7.0.34.tar.gz

Start Tomcat 7

Under your install directory /home/zoomer/apache-tomcat-7.0.34/bin execute startup.sh script

[zoomer@oel6 bin]$ ./startup.sh
Using CATALINA_BASE:   /home/zoomer/apache-tomcat-7.0.34
Using CATALINA_HOME:   /home/zoomer/apache-tomcat-7.0.34
Using CATALINA_TMPDIR: /home/zoomer/apache-tomcat-7.0.34/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /home/zoomer/apache-tomcat-7.0.34/bin/bootstrap.jar:/home/zoomer/apache-tomcat-7.0.34/bin/tomcat-juli.jar

Stop Tomcat 7

Under your install directory /home/zoomer/apache-tomcat-7.0.34/bin execute shutdown.sh script

[zoomer@oel6 bin]$ ./shutdown.sh
Using CATALINA_BASE:   /home/zoomer/apache-tomcat-7.0.34
Using CATALINA_HOME:   /home/zoomer/apache-tomcat-7.0.34
Using CATALINA_TMPDIR: /home/zoomer/apache-tomcat-7.0.34/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /home/zoomer/apache-tomcat-7.0.34/bin/bootstrap.jar:/home/zoomer/apache-tomcat-7.0.34/bin/tomcat-juli.jar

Access to Apache Tomcat 7 via web browser

Now you can access to Tomcat 7 using [http://localhost:8080]

Manager user configuration

If you try to access to the Manager application you get an unauthorized error. You need to set the manager user:

Set the credentials in conf/tomcat-users.xml file

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

In Tomcat 7 the roles required to use the manager application, were changed from single mangager role to the following four roles:

  • manager-gui - allows access to the HTML GUI and the status pages
  • manager-script - allows access to the text interface and the status pages
  • manager-jmx - allows access to the JMX proxy and the status pages
  • manager-status - allows access to the status pages only