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 :
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"
Step 2:create a directory using below command
# mkdir /usr/java
Step 3:Now unpack the zip file in /usr/java using tar command
# tar zxpvf jdk-7u9-linux-x64.tar.gz -C /usr/java/
This will create the directory /usr/java/jdk1.7.0_09 . This will be our JAVA_HOME
Step 4:Now we set the Java Home and will put Java into the path of our users using below command
# JAVA_HOME=/usr/java/jdk1.7.0_09/
# export JAVA_HOME
# PATH=$JAVA_HOME/bin:$PATH
# export PATH
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
Step 1:First download the zipped file using the the below url
“http://tomcat.apache.org/download-70.cgi”
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”
Step 3:Now we will create a script called “tomcat” under /etc/init.d directory .
# vi tomcat
#!/bin/bash
# description: Tomcat Start Stop Restart
# processname: tomcat
# chkconfig: 234 20 80
JAVA_HOME=/usr/java/jdk1.7.0_09
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
Save and exit the file
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
Step 5:Now start the tomcat service
# /etc/init.d/tomcat start
similarly we stop and restart the tomcat service.
Step 6:We can now access the Tomcat Manager page at:
http://yourdomain.com:8080
Is there any other alternative ?
Thanks,
Sandilya
Can anyone please tell me why
sh $CATALINA_HOME/bin/shutdown.sh is used in start) case.
As per my understanding here we only want to start tomcat so why we are calling shutdown.sh
Please help to understand.
Thanks,
Vinayak
;;
what is CATALINA_HOME=/usr/share/apache-tomcat-7.0.32.
why should we add this parameter.
I read this article, this is very useful & simple configuration procedure.Thanks
i am new to this linux and i have read this article.
this is useful to me.
but i think you have missed one line at tomcat file in init.d.
say.,
case $1 in
start)
sh $CATALINA_HOME/bin/startup.sh
;;
stop)