nginx源码开机启动脚本

#!/bin/bash
# chkconfig: 2345 99 20
# description: Nginx Service Control Script
PROG="/usr/local/nginx/sbin/nginx"
PIDF="/usr/local/nginx/logs/nginx.pid"
PROG_FPM="/usr/local/sbin/php-fpm"
PIDF_FPM="/usr/local/php5/var/run/php-fpm.pid"
case "$1" in
  start)
   $PROG -t &> /dev/null
   if [ $? -eq 0 ] ; then 
    $PROG
    $PROG_FPM
    echo "Nginx service start success."
   else
    $PROG -t
   fi
    ;;
  stop)
    kill -s QUIT $(cat $PIDF)
    kill -s QUIT $(cat $PIDF_FPM)
    echo "Nginx service stop success." 
    ;;
  restart)
    $0 stop
    $0 start
    ;;
  reload)
   $PROG -t &> /dev/null
   if [ $? -eq 0 ] ; then
    kill -s HUP $(cat $PIDF)
    echo "reload Nginx config success."
   else
    $PROG -t
   fi 
    ;;
  *)
   echo "Usage: $0 {start|stop|restart|reload}"
   exit 1
esac
 

你可能感兴趣的:(nginx,shell脚本)