In this tutorial we will cover the steps needed to install Apache Tomcat on your CentOS 6.4, Debian or Ubuntu platform. Apache Tomcat is open source web server and servlet container developed by the Apache Foundation. It is used for Java Servlet and JSP application deploying. The service requires Java to be installed on the server in order to be running correctly.

Requirements

  • CentOS 6.4, Debian or Ubuntu installed on your computer/server
  • SSH access (Command line access to the server)
  • root privileges
  • Basic skills for working on a Linux environment

Install JDK

CentOS 6.4

The latest JDK package can be downloaded from the official website.

Bear in mind that the JDK is specific to 32 and 64 bit versions. In this article we will use 64-bit version. The package will be installed inside a newly created folder /usr/java:

Download and extract the package inside the /usr/java folder:

A folder called jdk1.8.0_05 will be extracted which we will use as Java home folder. In order for the configuration to be saved permanently we should edit the user's ~/.bash_profile file:

Once done you should log out from the current SSH session and then log back again.

Debian/Ubuntu:

For the JDK installation we will use the default package manager included inside the corresponding Linux distribution:

After that you will need to set Java home folder. We can do that by editing the file ~/.bashrc and adding the following line inside:

Once done you should log out fro the current SSH session and then log back again.

Install Apache Tomcat

CentOS 6.4:

The Apache Tomcat package will be installed inside a newly created folder /usr/share/tomcat:

Download the package from the official website http://tomcat.apache.org/download-70.cgi and extract the package inside the /usr/share/tomcat folder:

After that you should just start the service:

The following output should be displayed inside the terminal:

Debian/Ubuntu:

The default package manager (aptitude) can be used for the installation of Apache Tomcat:

You will be prompted to accept the installation. After that you can start the service:

Make sure that the default port 8080 is allowed on the server:

Test the functionality of the Apache Tomcat service

Once the installation is completed you can test the Apache Tomcat service using your browser:

or

where X.X.X.X is your server's IP address, i.e. http://1.2.3.4:8080

You should be able to see the default Apache Tomcat page inside your browser.

An easy way to find your server's IP address is to execute the following command:

Start Up Apache Tomcat automatically on server boot

CentOS 6.4:

Here is a simple script which can be used upon boot up of the system:

Save the script inside a file /etc/init.d/tomcat and set executable permissions:

After that you can add the script to the system boot up hierarchy:

Debian/Ubuntu:

At the end you should have a working Apache Tomcat web server software.