Manual Installation of Tomcat from Zip file on Ubuntu 12.04:

You can use this guide to manually install the glassfish on Ubuntu 12.04 Server

1)      Visit http://tomcat.apache.org/ to download the latest tomcat installer

2)      Unzip it with tar -zxvf Tomcatxxx.tar



                          tar -zxvf apache-tomcat-6.0.16.tar.gz

3)      Move the folder contents to the required directory. In my case, it is /app/tomcat directory

4)      Now create an user tomcat to run the tomcat service under this username. Also change the directory permissions to tomcat



#useradd tomcat

Or


#adduser tomcat


#chown -R tomcat:tomcat /app/tomcat/


#chmod 775 
-R /app/tomcat

5)      Check whether java is already installed by sung this command


#java –version
If it is not installed, then refer this post to install JDK or refer this post to install JRE

6)      Create a file called tomcat in the following path /etc/init.d/ to create tomcat service file. It should have the following lines in it


export CATALINA_HOME=”/app/tomcat”
case “$1″ in
start)
tomcat_id=$(ps -ef | grep $CATALINA_HOME | grep -v grep | awk ‘{print $2}’ | head -n 1)
if [ -n "$tomcat_id" ]
then
echo “Tomcat is already Running with PID:” $tomcat_id
else
echo “Starting tomcat from $CATALINA_HOME”
sudo -u tomcat authbind –deep $CATALINA_HOME/bin/startup.sh
fi
;;
stop)
tomcat_id=$(ps -ef | grep $CATALINA_HOME | grep -v grep | awk ‘{print $2}’ | head -n 1)
if [ -n "$tomcat_id" ]
then
echo “Stopping tomcat from $CATALINA_HOME”
sudo -u tomcat authbind –deep $CATALINA_HOME/bin/shutdown.sh
else
echo “Tomcat is not running”
fi
;;
status)
tomcat_id=$(ps -ef | grep $CATALINA_HOME | grep -v grep | awk ‘{print $2}’ | head -n 1)
if [ -n "$tomcat_id" ]
then
echo “Tomcat is Running with PID:” $tomcat_id
else
echo “Tomcat is not Running…….”
fi
;;
*)
echo $”usage: $0 {start|stop|status}”
exit 3
;;
esac

Note:

Install authbind if required by typing apt-get install authbind

7)      Finally apply 0755 permissions to tomcat file



#chown -R tomcat:tomcat /etc/init.d/tomcat 
#chmod 775 /etc/init.d/tomcat 

8)      Now you can start the tomcat using any of the following commands



# sh /app/tomcat/bin/startup.sh 
# /etc/init.d/tomcat start 

9)      To link the service in desired run levels in ubuntu server, install the following utility



 #apt-get install sysv-rc-conf 

10)   Then open the utility and enable the service in all run levels as shown in the screenshot



 # sysv-rc-conf 


11)   Done, tomcat is ready for use.

No comments:

Post a Comment