Showing posts with label Tomcat. Show all posts
Showing posts with label Tomcat. Show all posts

Tomcat directories explained

Here is brief summary of functions of various directories in tomcat
bin  : The bin directory contains the shell scripts and batch files for starting . We use mainly startup.sh to start the catalina. Internally it gives call to catalina.sh file to execute. The envorionment variables of JAVA_HOME , CATALINA_HOME are mandatory for tomcat catalina.sh to work.

conf : The conf directory contains the configuration files for Tomcat. These include general server configuration files, a default user list for file-based authentication and security for Web applications, and a global configuration

logs : The <TOMCAT_HOME>/logs directory contains the server logs.

lib : The <TOMCAT_HOME>/lib directory contains all the JAR files used by Tomcat.

webapps : This directory contains all the Web applications provided with Tomcat by default.
work : The work directory contains temporary files, precompiled JSP pages, and other intermediate files.

webapps : This is the place where we will place our war files . Tomcat automatically explodes them into directories. Tomcat also has applications of manager and host-manager which allows us to manage applications and hosts respectively.

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