Linux under Nginx startup, shutdown, reload scripts

Source: Internet
Author: User

Turn from: http://www.cnblogs.com/likehua/p/4015074.html
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 #! /bin/sh# Default-Start:     2345# Default-Stop:      01 6# Short-Description: starts the nginx web serverPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/binDESC="nginx daemon"NAME=nginx<span style="color: #ff0000;"><strong>DAEMON=/usr/local/nginx/sbin/$NAMECONFIGFILE=/usr/local/nginx/conf/$NAME.confPIDFILE=/usr/local/nginx/logs/$NAME.pid</strong></span>SCRIPTNAME=/etc/init.d/$NAMEset -e[ -x "$DAEMON"] || exit 0do_start() { $DAEMON -c $CONFIGFILE || echo -n "nginx already running"}do_stop() { kill -INT `cat $PIDFILE` || echo -n "nginx not running"}do_reload() { kill -HUP `cat $PIDFILE` || echo -n "nginx can‘t reload"}case"$1"in start) echo -n "Starting $DESC: $NAME" do_start echo "." ;; stop) echo -n "Stopping $DESC: $NAME" do_stop echo "." ;; reload|graceful) echo -n "Reloading $DESC configuration..." do_reload echo "." ;; restart) echo -n "Restarting $DESC: $NAME" do_stop do_start echo "." ;; *) echo "Usage: $SCRIPTNAME {start|stop|reload|restart}">&2 exit 3 ;;esac exit 0

Note: The red place to modify according to the actual path, the above script named Nginx, saved to the/ETC/INIT.D directory. Attempting to/etc/init.d/nginx the start command will report an "Insufficient permissions" error and execute chmod +x/etc/init.d/nginx to assign execute permissions to it.

This script can be executed in a way that:

/etc/init.d/nginx start

/etc/init.d/nginx Sttop

/etc/init.d/nginx Reload

/etc/init.d/nginx restart

If you want this script to boot from the start also need to be in the script head home chkconfig xx xx and other comments (specifically need to refer to the chkconfig command usage), let IT support Chckconfig and then execute/sbin/chkconfig nginx on command. At the same time, you can sudo/sbin/chkconfig--list nginx to see the effect.

Linux under Nginx startup, shutdown, reload scripts

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.