You are on page 1of 7

Apache Tomcat Installation

Installing Apache Tomcat on Linux

Abbaq Nadeem

Page 1

Apache Tomcat Installation

Table of Contents
Installing Apache Tomcat on Linux ...................................................................................................................1 Installing Java Runtime Environment .........................................................................................................................3 Installing Java Runtime Environment .....................................................................................................................4 Installing Tomcat Software .........................................................................................................................................5 Starting/Stopping Tomcat ..................................................................................................................................6

Abbaq Nadeem

Page 2

Apache Tomcat Installation

Installing Java Runtime Environment

Abbaq Nadeem

Page 3

Apache Tomcat Installation

Installing Java Runtime Environment


To run Tomcat, you need Java Standard Edition (Java SE), also known as the JDK. For the Tomcat installation I used SUN's latest Java SE JDK that was available at the time of this writing: Java SE Development Kit (JDK) 6 Update 10 (6u10). Regarding Java SE 6, Platform Name and Version Numbers, see http://java.sun.com/javase/6/webnotes/version-6.html. For my 64-bit Debian system I selected the 64-bit JDK multiplatform binary for Linux: jdk-6u10linux-x64.bin. I downloaded the binary file to /tmp and installed it as follows as root: # mkdir -p /usr/java # cd /usr/java # # chmod 700 /tmp/jdk-6u10-linux-x64.bin # /tmp/jdk-6u10-linux-x64.bin ... creating: jdk1.6.0_10/ creating: jdk1.6.0_10/db/ creating: jdk1.6.0_10/db/bin/ ... Done. # export JAVA_HOME=/usr/java/jdk1.6.0_10 # export PATH=$JAVA_HOME/bin:$PATH # # which java /usr/java/jdk1.6.0_10/bin/java # java -version java version "1.6.0_10" Java(TM) SE Runtime Environment (build 1.6.0_10-b33) Java HotSpot(TM) 64-Bit Server VM (build 11.0-b15, mixed mode)

Abbaq Nadeem

Page 4

Apache Tomcat Installation

Installing Tomcat Software

Abbaq Nadeem

Page 5

Apache Tomcat Installation

Download the latest Tomcat 6.x version from http://tomcat.apache.org/download-60.cgi. For Debian I downloaded the Binary Core Distribution file apache-tomcat-6.0.18.tar.gz which was the latest version at the time of this writing. Once you downloaded the tar file make sure the MD5 checksum matches the value posted on Tomcat's web site, see http://www.apache.org/dist/tomcat/tomcat-6/v6.0.18/bin/apache-tomcat6.0.18.tar.gz.md5: # md5sum /tmp/apache-tomcat-6.0.18.tar.gz 8354e156f097158f8d7b699078fd39c1 /tmp/apache-tomcat-6.0.18.tar.gz Installing Tomcat from a binary release (tar file) requires manual creation of the Tomcat user account. This is not necessary if you install the Tomcat RPM package on a Linux system that supports RPMs.

Next I extracted the tar file to /var/lib and changed the ownership of all files and directories to tomcat: # cd /var/lib # tar zxvf /tmp/apache-tomcat-6.0.18.tar.gz # chown -R tomcat.tomcat /var/lib/apache-tomcat-6.0.18 The get the Tomcat version of the newly installed Tomcat, run: # /var/lib/apache-tomcat-6.0.18/bin/version.sh Using CATALINA_BASE: /var/lib/apache-tomcat-6.0.18 Using CATALINA_HOME: /var/lib/apache-tomcat-6.0.18 Using CATALINA_TMPDIR: /var/lib/apache-tomcat-6.0.18/temp Using JRE_HOME: /usr Server version: Apache Tomcat/6.0.18 Server built: Jul 22 2008 02:00:36 Server number: 6.0.18.0 OS Name: Linux OS Version: 2.6.18-6-amd64 Architecture: x86_64 JVM Version: 1.4.2 JVM Vendor: Free Software Foundation, Inc. #

Starting/Stopping Tomcat
Now try to startup the Tomcat server to see whether the default Tomcat home page is being displayed.
Abbaq Nadeem Page 6

Apache Tomcat Installation


For security reasons I don't run the Tomcat server as user root but as tomcat which was created with no login shell. Therefore, to run Tomcat use the su command with the -p option to preserves all the environment variables when switching to tomcat (more on the Tomcat environment variables later). And since the tomcat account has no login shell, it needs to be specified with the -s option. (You may want to use this su command if you plan on writing and implementing a system startup and shutdown script for system reboots.) # export JAVA_HOME=/usr/java/jdk1.6.0_10 # export PATH=$JAVA_HOME/bin:$PATH # export CATALINA_HOME=/var/lib/apache-tomcat-6.0.18 # export CATALINA_BASE=/var/lib/apache-tomcat-6.0.18 # # su -p -s /bin/sh tomcat $CATALINA_HOME/bin/startup.sh Using CATALINA_BASE: /var/lib/apache-tomcat-6.0.18 Using CATALINA_HOME: /var/lib/apache-tomcat-6.0.18 Using CATALINA_TMPDIR: /var/lib/apache-tomcat-6.0.18/temp Using JRE_HOME: /usr/java/jdk1.6.0_10 # Now verify that Tomcat was started successfully by opening the URL http://localhost:8080 (Port number 8080 is the default port used by Tomcat). Note that you should also be able to use the name of your server instead of localhost. Once you opened the URL in your browser you should see Tomcat's Congratulation page. If you don't see the page, check the log files under $CATALINA_HOME/logs (/var/lib/apache-tomcat-6.0.18/logs). Before you continue with the next steps, make sure to shut down Tomcat since we want to run the Tomcat server out of a separate application directory which is covered in the next chapter. # su -p -s /bin/sh tomcat $CATALINA_HOME/bin/shutdown.sh Using CATALINA_BASE: /var/lib/apache-tomcat-6.0.18 Using CATALINA_HOME: /var/lib/apache-tomcat-6.0.18 Using CATALINA_TMPDIR: /var/lib/apache-tomcat-6.0.18/temp Using JRE_HOME: /usr/java/jdk1.6.0_10 #

Abbaq Nadeem

Page 7

You might also like