interview question and answer

November 23, 2012

How To Install & Configure Tomcat 7 In Linux


To Install tomcat 7 first we need to install jdk-7 . So To install java (jdk-7) follow the below steps :

1.                Step 1: Download the tar file of java according to your architecture using this link
“http://www.oracle.com/technetwork/java/javase/downloads/index.html"
2.                 
3.                Step 2:create a directory using below command
# mkdir /usr/java
4.                 
5.                Step 3:Now unpack the zip file in /usr/java using tar command

# tar  zxpvf  jdk-7u9-linux-x64.tar.gz  -C  /usr/java/

6.                This will create the directory /usr/java/jdk1.7.0_09 . This will be our JAVA_HOME
7.                 
8.                Step 4:Now we set the Java Home and will put Java into the path of our users using below command
9.     
# JAVA_HOME=/usr/java/jdk1.7.0_09/
# export  JAVA_HOME
# PATH=$JAVA_HOME/bin:$PATH
# export PATH
10.   
11.  To set the JAVA_HOME permanently, we need to add above commands  to the ~/.bash_profile of the user (in this case, root) or we can add it /etc/profile and then source it to give to all users.

Now Install Tomcat 7 

1.                            Step 1:First download the zipped file using the the below url
“http://tomcat.apache.org/download-70.cgi”

2.                            Step 2:We will install tomcat under “/usr/share” directory , Now unzip the tomcat file using below command:
# tar zxpvf   /root/apache-tomcat-7.0.32.tar.gz -C /usr/share
This will create a directory  “/usr/share/apache-tomcat-7.0.32”

3.                            Step 3:Now we will create a script called “tomcat” under /etc/init.d directory .
4.                           

# vi tomcat

5.                            #!/bin/bash
# description:
 Tomcat Start Stop Restart
# processname: tomcat
#  chkconfig: 234 20 80
JAVA_HOME=/usr/java/jdk1.7.0_09
6.                            export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
CATALINA_HOME=/usr/share/apache-tomcat-7.0.32

case $1 in
start)
sh $CATALINA_HOME/bin/startup.sh
;;
sh $CATALINA_HOME/bin/shutdown.sh
;;
restart)
sh $CATALINA_HOME/bin/shutdown.sh
sh $CATALINA_HOME/bin/startup.sh
;;
esac
exit 0

7.                            Save and exit the file
8.                             
9.                            Step 4:Assign the right permissions to tomcat script and add to chckconfig utility using below commands

# cd  /etc/init.d
#  chmod 755 tomcat
# chkconfig --add  tomcat
# chkconfig  --level 35  tomcat on

10.                        Step 5:Now start the tomcat service 
# /etc/init.d/tomcat start
similarly we stop and restart the tomcat service.
11.                         
12.                        Step 6:We can now access the Tomcat Manager page at:
http://yourdomain.com:8080
or
http://yourIPaddress:8080

No comments: