nginx服务自动启动

前端之家收集整理的这篇文章主要介绍了nginx服务自动启动前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

下面是编程之家 jb51.cc 通过网络收集整理的代码片段。

编程之家小编现在分享给大家,也给大家做个参考。

#!/bin/bash
# Nginx Startup script for the Nginx HTTP Server
# it is v.0.0.2 version.
# chkconfig: - 85 15
# description: Nginx is a high-performance web and proxy server.
#              It has a lot of features,but it's not for everyone.
# processname: Nginx
# pidfile: /var/run/Nginx.pid
# config: /usr/local/Nginx/conf/Nginx.conf
Nginxd=/usr/local/Nginx/sbin/Nginx
Nginx_config=/usr/local/Nginx/conf/Nginx.conf
Nginx_pid=/var/run/Nginx.pid
RETVAL=0
prog="Nginx"
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -x $Nginxd ] || exit 0
# Start Nginx daemons functions.
start() {
if [ -e $Nginx_pid ];then
   echo "Nginx already running...."
   exit 1
fi
   echo -n $"Starting $prog: "
   daemon $Nginxd -c ${Nginx_config}
   RETVAL=$?
   echo
   [ $RETVAL = 0 ] && touch /var/lock/subsys/Nginx
   return $RETVAL
}
# Stop Nginx daemons functions.
stop() {
        echo -n $"Stopping $prog: "
        killproc $Nginxd
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/Nginx /var/run/Nginx.pid
}
# reload Nginx service functions.
reload() {
    echo -n $"Reloading $prog: "
    #kill -HUP `cat ${Nginx_pid}`
    killproc $Nginxd -HUP
    RETVAL=$?
    echo
}
# See how we were called.
case "$1" in
start)
        start
        ;;
stop)
        stop
        ;;
reload)
        reload
        ;;
restart)
        stop
        start
        ;;
status)
        status $prog
        RETVAL=$?
        ;;
*)
        echo $"Usage: $prog {start|stop|restart|reload|status|help}"
        exit 1
esac
exit $RETVAL

以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

猜你在找的Shell相关文章