zoukankan      html  css  js  c++  java
  • Nginx的启动脚本(Centos)

    vim /etc/init.d/nginx
    service nginx start

    #!/bin/sh  
    # chkconfig: 2345 85 15  
    # description:Nginx Server  
      
    NGINX_HOME=/usr/local/nginx  
    NGINX_SBIN=$NGINX_HOME/sbin/nginx  
    NGINX_CONF=$NGINX_HOME/conf/nginx.conf  
    NGINX_PID=$NGINX_HOME/logs/nginx.pid  
      
    NGINX_NAME="Nginx"  
      
    . /etc/rc.d/init.d/functions  
      
    if [ ! -f $NGINX_SBIN ]  
    then  
        echo "$NGINX_NAME startup: $NGINX_SBIN not exists! "  
        exit  
    fi  
      
    start() {  
        $NGINX_SBIN -c $NGINX_CONF  
        ret=$?  
        if [ $ret -eq 0 ]; then  
            action $"Starting $NGINX_NAME: " /bin/true  
        else  
            action $"Starting $NGINX_NAME: " /bin/false  
        fi  
    }  
      
    stop() {  
        kill `cat $NGINX_PID`  
        ret=$?  
        if [ $ret -eq 0 ]; then  
            action $"Stopping $NGINX_NAME: " /bin/true  
        else  
            action $"Stopping $NGINX_NAME: " /bin/false  
        fi  
    }  
      
    restart() {  
        stop  
        start  
    }  
      
    check() {  
        $NGINX_SBIN -c $NGINX_CONF -t  
    }  
      
      
    reload() {  
        kill -HUP `cat $NGINX_PID` && echo "reload success!"  
    }  
      
    relog() {  
        kill -USR1 `cat $NGINX_PID` && echo "relog success!"  
    }  
      
    case "$1" in  
        start)  
            start  
            ;;  
        stop)  
            stop  
            ;;  
        restart)  
            restart  
            ;;  
        check|chk)  
            check  
            ;;  
        status)  
            status -p $NGINX_PID  
            ;;  
        reload)  
            reload  
            ;;  
        relog)  
            relog  
            ;;  
        *)  
            echo $"Usage: $0 {start|stop|restart|reload|status|check|relog}"  
            exit 1  
    esac
  • 相关阅读:
    随堂练习
    随堂练习
    第六次安卓作业
    第五次安卓
    第四次安卓
    第二次安卓
    安卓作业
    第十八次上机
    第七周作业
    第六周作业
  • 原文地址:https://www.cnblogs.com/chjw8016/p/5952999.html
Copyright © 2011-2022 走看看