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
  • 相关阅读:
    解决NLPIR汉语分词系统init failed问题
    牛客小白月赛3---G 旅游(树形dp)
    蓝桥杯 能量项链 (区间dp)
    OpenJ_Bailian
    LeetCode#169 Majority Element
    LeetCode#171 Excel Sheet Column Number
    LeetCode#172 Factorial Trailing Zeroes
    this指针
    auto、register、extern以及static
    const与static
  • 原文地址:https://www.cnblogs.com/chenpingan/p/10544049.html
Copyright © 2011-2022 走看看