How to Start Automatic Tomcat or Apache service on Linux operating System..

Hi Guys,
              If You want to start automatically tomcat service during the boot time of  linux/centos operating system then dont worry go for the below simple steps.



                             Version: Apache-Tomcat-6.0.26 Installation:

Step [1] 
First we have to download and extract the tomcat
“apache-tomcat-6.0.26.tar.gz” from http://tomcat.apache.org/
Tomcat requires setting the JAVA_HOME variable. The best
way to do this is to set it in .bashrc file.
To make tomcat automatically start when we boot up the computer.
We can add script to make it auto-start and shutdown.

Step [2]: Make the file tomcat in /etc/init.d/

Step[3]: In the file tomcat paste the following text as per the requirement.
 
#Tomcat auto-start
#description : Auto-starts tomcat
#processname :tomcat
export JAVA_HOME=/usr/src/java/jdk1.6.0_17
case $1 in
start)
sh /usr/src/apache-tomcat/apache-tomcat-6.0.26/bin/startup.sh
;;
Stop)
sh /usr/src/apache-tomcat/apache-tomcat-6.0.26/bin/shutdown.sh
;;
restart)
sh /usr/src/apache-tomcat/apache-tomcat-6.0.26/bin/shutdown.sh
sh /usr/src/apache-tomcat/apache-tomcat-6.0.26/bin/startup.sh
;;
esac
exit 0
Step [4]: Then save the file.

Step [5]: Make the script Executable by chmod command.

#sudo chmod 755 /etc/init.d/tomcat

Step [6]: Restart the computer .

Step [7]: Now give the URL: http://localhost:8080/
 on web Browser for accessing tomcat home page.


                          Version: Apache-Tomcat-5.5.28 Installation:

Step 1. 
First we have to download and extract the tomcat “apache-tomcat-5.5.28.tar.gz” from
http://tomcat.apache.org/
Place the extract file of tomcat in /usr/src/tomcat/ or wherever you want.

 Tomcat requires setting the JAVA_HOME variable. The best way to do this is to set it in .bash_profile file.
           For Automatic startup of apache-tomcat at boot time.
Step 2.
Save the below mentioned script in /etc/init.d/ directory with tomcat named file
Note: Use correct path of catalina.sh in PROGRAM
#!/bin/sh
# chkconfig: - 85 15
# description: Tomcat is a servlet container
#PROGRAM=$CATALINA_HOME/bin/catalina.sh
PROGRAM=/usr/src/tomcat/apache-tomcat-5.5.28/bin/startup.sh
if [ -f $PROGRAM ]; then
echo “$1ing” `basename $0`
su - root -c “$PROGRAM $1_
fi
Now run the following command on terminal.
To give the 755(read and execute) permission for all users of  “tomcat” script file.


# chmod 755 /etc/init.d/tomcat

Step 3.
Activate the script “tomcat” for automatic start the service in /etc/init.d/ or /etc/rc.d/init.d/
 
#chkconfig --add tomcat
#chkconfig --level 345 tomcat on
Step 4.
Test the script.
#service tomcat start

Step5.
Restart system and type on URL http://localhost:8080/
Now we can see the tomcat home page on the browser.


Gud luck..:)


Comments

Popular posts from this blog

Window could not start the Apache tomcat 6 on Local Computer.For more information, review the System Events Logs.If this is a non-Microsoft service,contact service vendor, and refer to service-specific error code 0.

How to Read Excel File in VC++....

ORACLE DBA INTERVIEW QUESTION & ANSWERS