zoukankan      html  css  js  c++  java
  • 将nginx交给service管理

    #!/bin/bash
    # chkconfig: 2345 99 99
    prot=80
    nginx=/usr/local/nginx/sbin/nginx
    check(){
    ! $nginx -tq && echo "致命错误:配置文件错误" && exit
    }
    start(){
    check
    netstat -tln |grep -q ":80>" && echo "$prot端口被占用" && exit
    $nginx
    }
    stop_reload(){
    check
    ! netstat -tlnp |grep -q "nginx" && echo "nginx 未运行"
    $nginx -s $1 &> /dev/null
    }
    case "$1" in
    start)
            start ;;
    stop)
            stop_reload $1 ;;
    restart)
            stop_reload stop &> /dev/null
            start ;;
    reload)
            stop_reload $1 ;;
    *)
            echo "用法:$(basename $0) <start|stop|restart|reload>" ;;
    esac

    将此脚本放至/etc/init.d/下即可用service启停

    将nginx添加到chkconfig管理的开机启动中

      chkconfig --add nginx

      chkconfig nginx on

  • 相关阅读:
    记在百度(熊场)的一次面试
    smarty模板引擎的整理
    图片轮播原理
    递归遍历目录及删除文件
    Java入门
    Java入门
    Java入门
    Java入门
    开课导读
    Java入门
  • 原文地址:https://www.cnblogs.com/Xinenhui/p/13916442.html
Copyright © 2011-2022 走看看