zoukankan      html  css  js  c++  java
  • nginx的自动化安装和启停脚本

    个人原创,转载请注明出处和作者,否则依法追究法律责任

    author: headsen chen

    date:  2018-03-07  14:39:11

    nginx_install.sh

    #!/bin/bash
    NGINX=nginx-1.9.3.tar.gz
    useradd nginx
    yum -y install gcc* pcre* zlib zlib-devel openssl*
    cd /tmp
    if [ -f $NGINX ];then
    continue
    else
    wget http://nginx.org/download/$NGINX
    tar fx $NGINX
    fi
    cd nginx-1.9.3 && ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-pcre --with-http_ssl_module --with-http_stub_status_module && make && make install

    [root@localhost init.d]# cat nginx
    #!/bin/bash
    start(){
    /usr/local/nginx/sbin/nginx
    if [ $? -eq 0 ];then
    echo -e "The process nginx start                                   [ 33[032mok33[0m ]"
    else
    echo -e "The process nginx start                                   [ 33[031mfalse33[0m ]"
    fi
    }
    stop(){
    kill -9 `ps -ef |grep nginx: |awk '{print $2}'` >/dev/null 2>&1
    if [ $? -eq 0 ];then
    echo -e "The process nginx stop                                   [ 33[032mok33[0m ]"
    else
    echo -e "The process nginx stop                                    [ 33[031mfalse33[0m ]"
    fi
    }
    restart(){
    stop
    start
    }
    case $1 in
    start)
    start
    ;;
    stop)
    stop
    ;;
    restart)
    restart
    ;;
    *)
    echo "The usage of number must be in start|restart|stop"
    ;;
    esac

    chmod +x /etc/init.d/nginx

    chmod +x ngins_install.sh

  • 相关阅读:
    MySQL查询缓存
    MySQL复制相关参数详解
    MySQL复制机制
    MySQL数据库的多表查询操作
    MySQL数据库单表查询基本操作及DML语句
    Hadoop大数据系列汇总
    MySQL数据库之日志功能详解
    MySQL数据库扫盲
    MySQL数据库之数据类型及基本使用详解
    MySQL数据库之日志管理
  • 原文地址:https://www.cnblogs.com/kaishirenshi/p/8522304.html
Copyright © 2011-2022 走看看