Linux set up tomcat boot __linux

Source: Internet
Author: User

Step One: Create a new file Tomcat under/ETC/INIT.D (requires root operation permission)

Vi/etc/init.d/tomcat

Then click "I" to write down the following code, Tomcat self-startup script

(Note: You need to modify the following 3 sections of the path "Export jre_home=/usr/jdk1.8.0_131", "Export Catalina_home=/usr/tomcat6", "Export catalina_base=/ Usr/tomcat6 ")

#!/bin/sh
# chkconfig:345 99 10
# Description:auto-starts Tomcat
#/etc/init.d/tomcat
# Tomcat Auto-start
# Source function library.
#. /etc/init.d/functions
# source Networking configuration.
#. /etc/sysconfig/network
Retval=0
Export jre_home=/usr/jdk1.8.0_131
Export CATALINA_HOME=/USR/TOMCAT6
Export CATALINA_BASE=/USR/TOMCAT6
Start ()
{
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 Tomcat | grep apache-tomcat|grep-v grep | Grep-v PID | awk ' {print $} ' |xargs kill-9
echo "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
;;
Esac

Exit $RETVAL

Finally click "Esc" and enter ": Wq"

Step two, set permissions

chmod +x/etc/init.d/tomcat

third step, set up boot service

sudo chkconfig tomcat on

Step Fourth, verify

Reboot the server, and then access

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.