Tutorial

How To Install Apache Tomcat on Ubuntu 12.04

Published on July 27, 2012
How To Install Apache Tomcat on Ubuntu 12.04

Status: Deprecated

This article covers a version of Ubuntu that is no longer supported. If you are currently operate a server running Ubuntu 12.04, we highly recommend upgrading or migrating to a supported version of Ubuntu:

Reason: Ubuntu 12.04 reached end of life (EOL) on April 28, 2017 and no longer receives security patches or updates. This guide is no longer maintained.

See Instead:
This guide might still be useful as a reference, but may not work on other Ubuntu releases. If available, we strongly recommend using a guide written for the version of Ubuntu you are using. You can use the search functionality at the top of the page to find a more recent version.

About Apache Tomcat

Apache tomcat is a Java based application server released by the Apache Software Foundation. It is a web server and a servlet container for Java web applications.

Setup

Tomcat installation on a virtual private server is relatively easy. Its single required dependency is Java and this tutorial will include a step on how to install that platform.

You do need to have a user with sudo privileges for this tutorial.

Step One—Install Tomcat

The most recent version of Tomcat is 7, and it can be easily downloaded through apt-get or from the Apache Tomcat site.

You can download it through apt-get by typing:

sudo apt-get install tomcat7

To download tomcat from their site, copy the link for the tar.gz package under the “Core” section and begin the download. You will get a link that originates from one of Apache’s many mirrors, making the command look mostly like this (although coming from a different site).

wget http://apache.mivzakim.net/tomcat/tomcat-7/v7.0.57/bin/apache-tomcat-7.0.57.tar.gz

After the download completes, untar the file.

tar xvzf apache-tomcat-7.0.57.tar.gz

Finish up the Tomcat installation on the VPS by moving the files to a convenient directory.

sudo mv apache-tomcat-7.0.57  ~/path/to/tomcat

Step Two—Install Java

We installed the entire Apache Tomcat server on our virtual server in the previous step. Before we can use it, however, we do need to have Java installed on the VPS as well. If you currently do not have java, you can download it quite easily with apt-get.

sudo apt-get install default-jdk

Once you have Tomcat and Java installed on the virtual private server, all that remains is to start them.

Step Three—Configure .bashrc

In order to start Tomcat, we need to add it as an environment variable in the /.bashrc file.

sudo nano ~/.bashrc

You can add this information to the end of the file:

export JAVA_HOME=/usr/lib/jvm/default-java
export CATALINA_HOME=~/path/to/tomcat

Save and exit out of .bashrc. You can make the changes effective by restarting the bashrc file.

. ~/.bashrc

Step Four—RESULTS

Tomcat is now installed and configured on our virtual servers. However, it is not yet activated.

The final step is to activate Tomcat by running its startup script:

$CATALINA_HOME/bin/startup.sh

Once that runs, Tomcat is up and ready on port 8080.

You can visually verify that Tomcat is working by accessing your server page at your_IP_address:8080.

It should look like this

By Etel Sverdlov

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the authors

Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
10 Comments


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Very good! Congratulartions!

we should have particular version of jdk for tomcat 7 to be installed on system?

Anyone please help me i m getting error in installing tomcat7 on ubuntu 12.04 …

this is a problem

-bash: /home/ck/path/to/tomcat/bin/startup.sh: No such file or directory

when i download tomcat form their site , system show this message "wget: unable to resolve host adress “.atlanticmetro.net” " now what should i do ???

I already successfully install tomcat 7 it’s started now, but why it’s not accessible from browser, I try to open my_ip_addredd:8080 on browser the screen just keep blank with no respond displayed, any solution for this issue ?

I followed this tutorial to setup a new user - https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-12-04

Later I tried to start the tomcat by following this tutorial but tomcat always stuck at INFO: Deploying web application directory /path/to/tomcat/apache-tomcat-7.0.41/webapps/docs

Here is a Blog to make multiple instances via Apache Tomcat server. Apache Tomcat

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.