How to install Apache Tomcat

Apache Tomcat is a web server for multiple operating systems, including CentOS. It's open-source software developed by the Apache Software Foundation, so it's available for free under the Apache license. Apache Tomcat is written in Java, and uses JavaServer Pages and Java servlets to create a pure Java runtime environment. It runs as a single process in its simplest configuration, although Tomcat processes each HTTP request from the browser as a separate thread. The procedure for installing Tomcat generally involves installing the Java Development Kit (JDK), configuring the system environment, downloading Tomcat and installing it.

DIFFICULTY Basic - 1 | Medium - 2 | Advanced - 3
RELATED PRODUCTS Linux-based VPS or dedicated servers

Here is a quick tutorial on how to install Apache Tomcat.

NOTE: cPanel/WHM users should follow cPanel's instructions instead to use EasyApache

Install the JDK

Assume for this example that you wish to develop Java programs in addition to installing the JDK. Assume further that the current version of JDK is v1.7.0, and you want to automatically answer "yes" to all questions that the installation program asks. Enter the following command at the CentOS command line:

$ sudo yum install java-1.7.0-openjdk-devel -y

Set the JAVA_HOME environment variable

Set JAVA_HOME to the location of JDK, which is /usr/lib/jvm/java-1.7.0-openjdk by default.

$ sudo sh -c 'echo export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk > /etc/profile.d/'
$ source /etc/profile.d/

Download Apache Tomcat

Download the Tomcat binary. The following command assumes that the current version of Tomcat is v7.0.56:

$ wget

NOTE: Always check to ensure you are downloading the latest version. Version 7.0.56 was current at the time of writing.

Unpack and configure

Unpack the binary file with the tar command:

$ sudo tar xvzf apache-tomcat-7.0.56.tar.gz -C /opt

Make the unpacked files read-only;

$ sudo chmod +r /opt/apache-tomcat-7.0.56/conf/*

Set CATALINA_HOME to the directory for the Tomcat files

$ sudo sh -c 'echo export CATALINA_HOME=/opt/apache-tomcat-7.0.56 > /etc/profile.d/'
$ source /etc/profile.d/

Start Tomcat

Run Tomcat's startup script.

$ sudo $CATALINA_HOME/bin/

Verify that Tomcat is running by going to http://localhost:8080 in your browser. This URL should appear as follows:

Change your Tomcat login credentials

You'll also need to update the password you use to log in to your Tomcat Manager. We've got thos instructions for you here.

Was This Article Helpful?
Thank You For Your Feedback
Glad we helped! Anything more we can do for you?
Sorry about that. How can we be more helpful?