1. Download Tomcat Download Linux version (tar.gz) from http://tomcat.apache.org/download-70.cgi link
2, unzip, upload and assign permissionsUnzip, use WINSCP to upload the extracted installation files to the/home/software/tomcat directoryand use chmod-r 755/home/software/tomcat to command account permissions.
3. Write and run the script that is installed as a serviceThe shell script is as follows:
#! /bin/sh#shell script takes care of starting and stopping# the GlassFish DAS and GlassFish instance.## chkconfig:-64 36# Description:tomcat Auto start#/etc/init.d/tomcatd# Tomcat auto-start# Source function library.#. /etc/init.d/functions# Source Networking configuration.#. /etc/sysconfig/networkretval=0export Jre_home=/usr/local/jdk1.7.0export catalina_home=/home/jinyuan/tomcat/ Tomcatjinyuan1export Catalina_base=/home/jinyuan/tomcat/tomcatjinyuan1start () {if [-F $CATALINA _HOME/BIN/STARTUP.S h]; Then echo $ "Starting Tomcat" $CATALINA _home/bin/startup.sh retval=$? echo "OK" return $RETVAL fi}stop () {if [-f $CATALINA _home/bin/shutdown.sh]; Then echo $ "stopping Tomcat" $CATALINA _home/bin/shutdown.sh retval=$? Sleep 1 Ps-fwwu Yhjhoo | grep apache-tomcat|grep-v grep | Grep-v PID | awk ' {print $} ' |xargs kill-9echo "OK" # [$RETVAL-eq 0] && rm-f/var/lock/... return $RETVAL fi}case "$" in Start) Start; stop) stop;; Restart) echo $ "restaring Tomcat" $ stop sleep 1 $ start; *) echo $ "Usage: $ Start|stop|restart}" exit 1;; Esacexit $RETVAL
named Tomcatoa (this name is the service name, which is available when the command is started), upload the script file to the/etc/init.d/directory with WINSCPand execute the following script: sudo chmod +x/etc/init.d/tomcatoa
Chkconfig--add Tomcatoa
Chkconfig Tomcatoa on
4. Start the service tomcatoa the start command with service
Linux (CentOS) installation Tomcat (installed as service with shell scripts)