Install tomcat in linux (centos) (use shell scripts to install tomcat as a service)

Source: Internet
Author: User
Tags glassfish

Install tomcat in linux (centos) (use shell scripts to install tomcat as a service)
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.






Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.