Install tomcat in linux (centos) (use shell scripts to install tomcat as a service) and centostomcat
1. Download tomcatDownload the linuxlinuxversion (tar.gz) from http://tomcat.apache.org/download-70.cgi)
2. decompress, upload, and grant permissionsDecompress the package, use WinSCP to upload the decompressed installation file to the/home/software/tomcat directory, and use the chmod-R 755/home/software/tomcat command to obtain the permission.
3. Compile and run the script installed as a service.The 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.sh ]; 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 $2}'|xargs kill -9 echo " OK" # [ $RETVAL -eq 0 ] && rm -f /var/lock/... return $RETVAL fi}case "$1" in start) start ;; stop) stop ;; restart) echo $"Restaring Tomcat" $0 stop sleep 1 $0 start ;; *) echo $"Usage: $0 {start|stop|restart}" exit 1 ;;esacexit $RETVAL
Name tomcatoa (this name is the service name, which can be used when started in command mode later), and use winscp to upload the script file to/etc/init. d/directory and execute the following Script: sudo chmod + x/etc/init. d/tomcatoa
Chkconfig -- add tomcatoa
Chkconfig tomcatoa on
4. Run the service tomcatoa start command to start the service.