How to Setup Tomcat on Ubuntu Server

How to install Tomcat and Apache on Ubuntu

Learn how to install Apache and Tomcat on a Linux server running Ubuntu, just in case you aren't already using the world's best Java host:

# prompt is root and $ prompt is the user prompt

1- Upload JDK bin - preferably Oracle Sun JDK.

(be sure to get 32 or 64 based on what you using for your OS)

# cd /usr/
# mkdir java
# cd java
# wget
# unzip

Note: If unzip does not work then do apt-get install unzip and try again.

2- Create symlink to simplify so that you can create path to it as /usr/java/jdk6

# ln -s jdk1.6.0_33 jdk6

3- Create user and home directory to host your tomcat and set shell to bash

# useradd -d /home/myapp -m myapp
# chsh myapp -s /bin/bash

4- Change to user and set JAVA_HOME

# su - myapp 
$ nano .bashrc

Add the following at the end of the file:

## JAVA_HOME variables
export JAVA_HOME

5- Save file then run following command to initialize.

$ . .bashrc

6- Test

$ java -version

You should get this output if it works:

java version "1.6.0_33"
Java(TM) SE Runtime Environment (build 1.6.0_33-b04)
Java HotSpot(TM) Client VM (build 20.8-b03, mixed mode)

7- Get apache tomcat

$ wget \\

8- Untar and create symlink

$ tar xvzf apache-tomcat-7.0.29.tar.gz
$ ln -s apache-tomcat-7.0.29 tomcat
$ rm apache-tomcat-7.0.29.tar.gz

9- Start up your tomcat container to see if it works

$ cd tomcat/bin
$ ./

10- Test your installation

Test by opening your browser and going to http://YOURIP:8080 and you should be greeted with the Tomcat welcome page.

Package your application into a WAR file and upload to your /home/myapps/tomcat/webapps/

  • 244 Users Found This Useful
Was this answer helpful?

Related Articles

Spring Framework

Need to develop Plain Old JAVA Objects? Want to have fun developing your application? Then we...

Subdomain Handling Tutorial

This tutorial explains how you can host subdomains with JavaPipe's Tomcat hosting. This is...

Pointer Domain Handling Tutorial

This tutorial explains how you can host pointer domains with a Java web hosting package from...

Choosing between JBoss7's Standalone or Domain features.

JBoss 7 introduced new feature called managed domains. Basically this is a multi-server...

How do I restart my tomcat?

However, if you have a private Tomcat instance with a Java host like us, then you have the...