You are on page 1of 3

Installing Apache Tomcat in Linux

Apache Tomcat is an open source software implementation of Java Servlet and JavaServer Pages technologies. Apache Tomcat powers numerous large-scale, mission-critical web applications across a diverse range of industries and organizations.

Procedure:
1. Install the latest version of Java Development kit. As of writing, the latest version of jdk is JDK 7u4. (http://www.oracle.com/technetwork/java/javase/downloads/index.html) . Choose the appropriate inistaller for your architecture. In this manual, the instructor is using a 32-bit Fedora Core 14. I'll be downloading jdk-7u4-linuxi586.tar.gz.

2. Move or copy the download jdk file to the /opt directory: # mv jdk-7u4-linux-i586.tar.gz /opt

3. Change directory to /opt and then extract the file. # cd /opt # tar -xvzf jdk-7u4-linux-i586.tar.gz

The last command will produce a directory named jdk1.7.0_04. You can rename the directory to your liking for better. The instructor renamed it to java7 #mv jdk1.7.0_04 java7

4. We need to setup our environment variables so that Java is made available everytime your Linux box boots up. We modify the following files
~/.bashrc ~/.bash_profile

and append at the end of each file the following:


export JAVA_HOME=/opt/java7 export PATH=$PATH:/opt/java7/bin

5. Test your jdk installation. You should log out and log back again and check if Java is seen by your Linux box. Upon executing the commands, you should have obtained similar results. $ echo $JAVA_HOME /opt/java $java -version java version "1.7.0_04" Java(TM) SE Runtime Environment (build 1.7.0_04-b04) Java HotSpot(TM) Server VM (build 22.1-b02, mixed mode)

6. Download Apache Tomcat 7 You can download the latest stable version of Apache Tomcat 7 at (http://tomcat.apache.org/download-70.cgi). The instructor downloaded apachetomcat-7.0.27.tar.gz 7. Move (mv) or copy (cp) the download gzip file to the /usr/share directory. # cp apache-tomcat-7.0.27.tar.gz /usr/share

Change directoryto /usr/share and extract the gzip file. # tar -xvzf apache-tomcat-7.0.27.tar.gz

The above command will produce a directory name apache-tomcat-7.0.27. You can rename this file to your liking. The instructor renamed the file to tomcat7 #mv apache-tomcat-7.0.27 tomcat7

8. Set a minimally privileged user to run tomcat. We change the ownership of the apache tomcat installation directory to erwin which is a minimally privileged user. # chown -Rf erwin:erwin /usr/share/tomcat7/

9. Run Apache Tomcat. $ /usr/share/tomcat7/bin/startup.sh Using CATALINA_BASE: /usr/share/tomcat7 Using CATALINA_HOME: /usr/share/tomcat7 Using CATALINA_TMPDIR: /usr/share/tomcat7/temp

Using JRE_HOME: /opt/java7 Using CLASSPATH: /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar

10. Shutdown Apache Tomcat $ /usr/share/tomcat7/bin/shutdown.sh

11. Start apache tomcat again and point your browser to http://localhost:8080

You might also like