In this article we will learn how to install tomcat on Linux (CentOS,Fedora and RedHat). For example we will install the tomcat 7 on CentOS operating system. Before starting tomcat installation, be sure that java should be installed on your system. I will show you in a sort, how to install java on linux. So first we will go through the steps of installing the JDK and than Tomat.
Installing JDK on Linux :
In my case, I am installing java and tomcat on the root directory's etc folder.
Step 1:
Go to your directory where you want to install the Java.
# cd /etc
create folder under etlzen using mkdir :
# mkdir java
Change directory to new directory:
# cd /etc/java/
Step 2: Download the JDK using command line
For 64 bit Linux use following command :
# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jdk-7u72-linux-x64.tar.gz"
For 32 bit Linux use following command :
# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jdk-7u72-linux-i586.tar.gz"
Step 3:
After downloading, Extract archive using following command.
# tar xzf jdk-7u72-linux-x64.tar.gz
Step 5: Installing JAVA
After extracting java archive file, we can now set JAVA_HOME and PATH system variables. To set it for your system, you can issue the following commands from the Command line:
JAVA_HOME=/etc/java/jdk1.7.0_72
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
You can also set the path permanently, open the .bashrc file and edit it as follows:
vi ~/.bashrc
add the following lines in this file
export JAVA_HOME=/etc/java/jdk1.7.0_72
export PATH=$PATH:$JAVA_HOME/bin
Now whenever you access the java from command prompt it will set the classpath automatically.
Step 6: Check JAVA Version
# java -version
If you found following output, it means java is installed and ready to use:
java version "1.7.0_72"
Java(TM) SE Runtime Environment (build 1.7.0_72-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode)
Installing Tomcat :
Step 1:
Go to your directory where you want to install the tomcat.
# cd /etc
Step 2:
Download the tomcat v7.0.57 using command
# wget http://www.us.apache.org/dist/tomcat/tomcat-7/v7.0.57/bin/apache-tomcat-7.0.57.tar.gz
Step 3:
After completing download, Extract archive using following command. Use archive file as per your system configuration.
# tar xzf apache-tomcat-7.0.57.tar.gz
Step 4: Start Tomcat
# cd /etc/apache-tomcat-7.0.57
# ./bin/startup.sh
Output :
Using CATALINA_BASE: /etc/apache-tomcat-7.0.57
Using CATALINA_HOME: /etc/apache-tomcat-7.0.57
Using CATALINA_TMPDIR: /etc/apache-tomcat-7.0.57/temp
Using JRE_HOME: /etc/java/jdk1.7.0_72
Using CLASSPATH: /etc/apache-tomcat- 7.0.57/bin/bootstrap.jar:/etc/apache-tomcat-7.0.57/bin/tomcat-juli.ja r
Tomcat started.
If above message shown on the command line, it means tomcat is started successfully
Step 5: Access Tomcat in Browser
http://localhost:8080
Step 6: Stop Tomcat
# cd /etc/apache-tomcat-7.0.57
# ./bin/shutdown.sh
0 Comment(s)