How to install Apache tomcat on Linux?

By | August 11, 2013

How to install Apache tomcat on Linux

apache_tomcat_linuxbrainboxApache Tomcat is an open source web application server which supports J2ee Servlets, JavaServer, Pages(JSP) and API’s. Tomcat should not be confused with Apache web server which is an HTTP web server.

Apache Tomcat can be configured by editing server.xml file.

Servlet is defined as a way to add dynamic content to a Web server using the Java platform & a servlet container is a compiled, executable program. The servlet container name in tomcat is catalina.

Prerequisites for installing Apache tomcat are
1. Java
2. JDK

Steps to install Apache tomcat

Step1 : Install all the prerequisites

Redhat :

#yum install java

Step2 : Download tomcat source package and un compress it.

#cd /opt
#wget http://apache.osuosl.org/tomcat/tomcat-8/v8.0.0-RC1/bin/apache-tomcat-8.0.0-RC1.tar.gz

#tar xvfz apache-tomcat-8.0.0-RC1.tar.gz

Step3 : Setup the paths for Catalina and others.
Setting catalina paths

Redhat

CATALINA_HOME=/opt/apache-tomcat-8.0.0-RC1
CATALINA_BASE=/opt/apache-tomcat-8.0.0-RC1

Setting java paths

Check what java versions are installed in your system

#update-alternatives –config java

This command will display which is default java version used by your machine.

Example output :

# update-alternatives –-config java

There are 2 programs which provide ‘java’.

Selection Command
———————————————–
1
/usr/lib/jvm/jre-1.4.2-gcj/bin/java
*+ 2
/usr/lib/jvm/jre-1.6.0-openjdk/bin/java

Enter to keep the current selection[+], or type selection number:

If you see above the default java version is 1.6 so set the path to/usr/lib/jvm/jre-1.6.0-openjdk

JAVA_HOME=/usr/lib/jvm/jre-1.6.0-openjdk
JDK_HOME=$JAVA_HOME

Step4 : Now start tomcat server

#/opt/apache-tomcat-8.0.0-RC1/bin/startup.sh

Sample output.

Using CATALINA_BASE: /opt/apache-tomcat-8.0.0-RC1
Using CATALINA_HOME: /opt/apache-tomcat-8.0.0-RC1
Using CATALINA_TMPDIR: /opt/apache-tomcat-8.0.0-RC1/temp
Using JRE_HOME:
/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/

Step5 : By default Apache Tomcat will be hosted on localhost : 8080 port by default. So try to access the site with web browser

http://localhost:8080
or
http://systemname:8080

Leave a Reply

Your email address will not be published. Required fields are marked *