zoukankan      html  css  js  c++  java
  • nginx服务搭建脚本

    #!/bin/bash
    
    # 安装依赖包,gcc gcc-c++是编译必装的工具包。而其他包是根据安装的模块依赖的包
    yum -y install gcc gcc-c++ pcre-devel zlib-devel openssl openssl-devel libxslt-devel GeoIP-devel perl-ExtUtils-Embed
    # 解压包,然后进入。并判断是否有指定的包存在 cd
    /usr/local/src  

    if [ ! -f nginx-1.12.2.tar.gz ] ; then
        echo "/usr/local/src下没有指定的nginx压缩包!"
        exit 1
    fi

    tar zxf nginx-1.14.2.tar.gz
    cd nginx-1.14.2

    # 取消debug编译模式,让整个程序更小,编译更快 sed -i '172s/^/#/' auto/cc/gcc
    # 配置,指定模块 .
    /configure --prefix=/usr/local/nginx --with-file-aio --with-http_auth_request_module --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module # 如果安装的是nginx-1.12.2使用上面的预编译不行,要使用下面的预编译,好像每个不同版本的包,支持的模块不尽相同
    # ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_v2_module --with-http_stub_status_module --with-pcre --with-http_gzip_static_module --with-http_dav_module   --with-http_addition_module  --with-http_sub_module --with-http_flv_module  --with-http_mp4_module

    # 编译,然后安装
    make && make install
    # 添加系统变量 sed -i '$a export PATH=/usr/local/nginx/sbin:$PATH' /etc/profile source /etc/profile
    # 生成服务启动脚本
    echo '#!/bin/bash # chkconfig: - 99 2 # description: Nginx Service Control Script PROG="/usr/local/nginx/sbin/nginx" PIDF="/usr/local/nginx/logs/nginx.pid" case "$1" in   start)   $PROG   ;;   stop)   kill -3 $(cat $PIDF)   ;;   restart)   $0 stop &> /dev/null   if [ $? -ne 0 ];then continue; fi   $0 start   ;;   reload)   kill -1 $(cat $PIDF)   ;;   *)   echo "Userage: $0 { start | stop | restart | reload }"   exit 1 esac exit 0 ' > /etc/init.d/nginx
    # 添加开机自启 chmod +x /etc/init.d/nginx chkconfig --add nginx chkconfig nginx on
    # 启动服务 service nginx start
  • 相关阅读:
    将springboot安装成windows服务启动。
    jackson将json数组转成List、普通数组。
    maven编译正常,运行报错:中没有主清单属性
    [SQL]SUTFF内置函数的用法 (删除指定长度的字符并在指定的起始点插入另一组字符)
    sql语句中charindex的用法 可用于截取字符串
    C# 中怎么将string转换成int型
    C#判断奇偶数的函數
    asp.net 下载Excel (数据流,不保存)--客户端
    C# DateTime 日期加1天 减一天 加一月 减一月 等方法(转)
    ASP.NET jquery ajax传递参数
  • 原文地址:https://www.cnblogs.com/chenpingan/p/10544049.html
Copyright © 2011-2022 走看看