Redhat – Can’t start tomcat as service in redhat

javaredhatservicetomcat

I'm new to Linux but having spent a whole day I Installed Java and Tomcat. My goal is to host an App with this Linux box. I know it all works fine from my windows based machine, but it is my laptop so I'm planning to use the Linux Box as my dedicated server.

I am following this tutorial . From this tutorial I have executed the following command :

cd /etc/init.d 
vi tomcat 
#!/bin/bash  
# description: Tomcat Start Stop Restart  
# processname: tomcat  
# chkconfig: 234 20 80  
JAVA_HOME=/usr/java/jdk1.7.0_05  
export JAVA_HOME  
PATH=$JAVA_HOME/bin:$PATH  
export PATH  
CATALINA_HOME=/usr/share/apache-tomcat-7.0.29  

case $1 in  
start)  
sh $CATALINA_HOME/bin/startup.sh  
;;   
stop)     
sh $CATALINA_HOME/bin/shutdown.sh  
;;   
restart)  
sh $CATALINA_HOME/bin/shutdown.sh  
sh $CATALINA_HOME/bin/startup.sh  
;;   
esac      
exit 0  
chmod 755 tomcat
chkconfig --add tomcat 
chkconfig --level 234 tomcat on 
chkconfig --list tomcat 
service tomcat start  

After this command , tomcat is started at port 8082 . But when I restart pc , the tomcat is not started with boot of PC .

How can I do this ?

Best Answer

Run the following command to set the service to start automatically:

chkconfig tomcat on