How to Install Apache Tomcat on Ubuntu 12.04

Introduction

 

Apache tomcat is an open source web server developed by Apache Software Foundation. It serves as a servlet container for Java based web applications.

The installation of Apache Tomcat on a virtual private server is relatively simpler.  The set up would require you to install Java on your system and we will show you how to do it later in this tutorial.

You also need to have a user with sudo privileges to perform the tasks.

 

Installation of Tomcat

 

You can download the latest version of Tomcat using apt-get from the official Apache Tomcat site.

Run the following command to begin installing:

sudo apt-get install tomcat7

In order to download tomcat from their site, you need to copy the link for tar.gz package inside ‘core’ section and begin the download. You will be provided with a link from one of Apache’s many mirrors. The command should almost look similar to this:

wget http://mirror.sitename.com/apache/tomcat/tomcat-7/v7.0.29/bin/apache-tomcat-7.0.29.tar.gz

Once the download completes, you should untar the file:

tar xvzf apache-tomcat-7.0.29.tar.gz

After that move the files to a convenient directory.

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

Tomcat is installed.

Installing Java

 

In order to use the installed Apache Tomcat, we do need to have Java installed on the VPS. Java can be installed by using the same apt-get tool:

sudo apt-get install default-jdk

Now that you have java and apache tomcat installed on your VPS, all you need to do is to start them.

 

Configure .bashrc

 

For starting Tomcat, you need to add it as an environment variable in file /.bashrc.

Open up the file /.bashrc:

sudo nano ~/.bashrc

Add the following lines to the end of line of the file:

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

Save the file and exit out of .bashrc.

Restart the bashrc file to bring in your changes into effect:

. ~/.bashrc

 

Activate Tomcat

 

The final step in the setting up of Apache Tomcat is the activation of Tomcat. That can be done by running the startup script:

$CATALINA_HOME/bin/startup.sh

Once the script runs, Tomcat will be up and ready at port 8080.

Verify the installation by accessing your server page by pointing to yourIP_address:8080.

It should almost look like this:

 

apache-tomcat

support2 has written 111 articles

Leave a Reply