How to install Tomcat in Linux (Ubuntu)

To install Tomcat we need Java to be installed in the system. If you want to know how to install Java on Linux you can refer this earlier post on the same.

We can install Java either using packages (apt , yum) or manually. This post explains how to do it manually.

The main advantage of doing it manually is that all the tomcat files are in one location. The automated installation will spread the setup files across various locations. It places the Tomcat configuration files at various non standard places.

Steps

1) Login to shell and go to folder where you want to install tomcat . In this example i am doing it in folder in /usr . The shell commands are shown by # statements , it can be $ for you. It doesn’t matter. If the user with which you are logged in is not root. Then you need to prefix commands with sudo.

# cd /usr

# sudo mkdir tomcat7

# cd tomcat7

Download the zip of tomcat files from tomcat website

# sudo wget http://mirror.metrocast.net/apache/tomcat/tomcat-7/v7.0.16/bin/apache-tomcat-7.0.16.zip

This will download the tomcat zip into tomcat7 directory , next you need to unzip it

# unzip apache-tomcat-7.0.16.zip

This will create a folder named apache-tomcat-7.0.16 in the tomcat 7 folder. The apache-tomcat-7.0.16 is your tomcat home ( CATALINA_HOME environment variable)

Setting up of tomcat environment and path variables

Both JAVA_HOME and CATALINA_HOME environment variables and its path is required for tomcat to run.

# export CATALINA_HOME=/usr/tomcat7/apache-tomcat-7.0.16

# export PATH=$PATH:$CATALINA_HOME/bin

Now its time to start the tomcat. But before this we need to give execute permissions to bin directory files of tomcat

# cd apache-tomcat-7.0.16/bin

# sudo chmod 775 *

If you run tomcat without giving execute permissions you will get error like

The BASEDIR environment variable is not defined correctly.

Time to start tomcat

# sudo sh startup.sh

You can test it by opening

http://localhost:8080 in the browser

Hope it was useful , please don’t forget to write your comments and suggestions

No comments:

Post a Comment

Please share your views and comments below.

Thank You.