Nginx 最新稳定版二进制编译升级脚本,实现一键升级.

    • 使用须知:

使用脚本前,确保机器已经安装了Nginx. 本脚本会添加一些常用且比较有用的模块. 脚本会从nginx.org直接下载最新的稳定版源码,进行编译. 已在Debian 8上通过测试. 除了安装依赖外,其余部分其他系统可照搬. 脚本运行完,自行重启Nginx即可.

  • 附加模块:
    • nchan
    • nginx-auth-pam
    • nginx-cache-purge
    • nginx-echo
    • nginx-lua
    • nginx-upstream-fair
    • ngx_http_substitutions_filter_module
  • 使用方法:
  • wget --no-check-certificate -qO- 'https://moeclub.org/attachment/LinuxShell/nginx_update.sh' |bash
    • 预览:
    • #!/bin/bash
      
      Debian_VER='jessie'
      Nginx_URL='http://nginx.org/packages/debian/pool/nginx/n/nginx/'
      
      Check_Status(){
        [ $? -eq '0' ] || exit 1
      }
      
      apt-get update
      apt-get install -f -y gcc make libexpat1 liblua5.1-0 libluajit-5.1-2 libluajit-5.1-common libluajit-5.1-dev libpam0g-dev zlib1g libxml2 libssl-dev libperl-dev libpcre3-dev libgd-dev libgoogle-perftools-dev p7zip-full
      Check_Status
      
      cd /tmp
      rm -rf ./nginx*
      
      Nginx_VER_TMP=$(wget --no-check-certificate -qO- "$Nginx_URL" |grep -o 'nginx_[^"]*' |grep -v '' |grep 'dsc$' |sort -nk 2 -t . |grep "$Debian_VER" |tail -n1)
      [ -n "$Nginx_VER_TMP" ] || Check_Status
      
      Nginx_VER_ORIG=$(echo "$Nginx_VER_TMP" |cut -d'-' -f1)
      [ -n "$Nginx_VER_ORIG" ] || Check_Status
      
      Nginx_VER_PATH=$(echo "$Nginx_VER_TMP" |cut -d'~' -f1)
      [ -n "$Nginx_VER_PATH" ] || Check_Status
      
      wget --no-check-certificate -qO 'nginx_modules.zip' 'https://moeclub.org/attachment/LinuxSoftware/nginx_modules.zip.deb'
      Check_Status
      
      wget --no-check-certificate -qO 'nginx.orig.tar.gz' "${Nginx_URL}${Nginx_VER_ORIG}.orig.tar.gz"
      Check_Status
      
      wget --no-check-certificate -qO "nginx.${Debian_VER}.tar.xz" "${Nginx_URL}${Nginx_VER_PATH}~${Debian_VER}.debian.tar.xz"
      Check_Status
      
      tar -xvf "nginx.orig.tar.gz"
      Check_Status
      cd ./nginx-*
      tar -xvf "../nginx.${Debian_VER}.tar.xz"
      Check_Status
      7z x "../nginx_modules.zip" -o./
      Check_Status
      
      ExtModule=''
      AddModules=' --add-module=./'
      for item in `find modules -maxdepth 1 -type d`
        do
          [ -n "$item" ] && [ -n "$(echo $item |grep '/')" ] && {
            AddModule="${AddModules}${item}"
            ExtModule="${ExtModule}${AddModule}"
          }
        done
      
      sed -i 's/^CFLAGS="$CFLAGS -g"$/#&/g' ./auto/cc/gcc
      Check_Status
      
      ./configure 
      --prefix=/usr/share/nginx 
      --conf-path=/etc/nginx/nginx.conf 
      --http-log-path=/var/log/nginx/access.log 
      --error-log-path=/var/log/nginx/error.log 
      --lock-path=/var/lock/nginx.lock 
      --pid-path=/run/nginx.pid 
      --modules-path=/usr/lib/nginx/modules 
      --http-client-body-temp-path=/var/lib/nginx/body 
      --http-fastcgi-temp-path=/var/lib/nginx/fastcgi 
      --http-proxy-temp-path=/var/lib/nginx/proxy 
      --http-scgi-temp-path=/var/lib/nginx/scgi 
      --http-uwsgi-temp-path=/var/lib/nginx/uwsgi 
      --with-pcre-jit 
      --with-ipv6 
      --with-threads 
      --with-http_addition_module 
      --with-http_auth_request_module 
      --with-http_flv_module 
      --with-http_gzip_static_module 
      --with-http_gunzip_module 
      --with-http_image_filter_module=dynamic 
      --with-http_mp4_module 
      --with-http_perl_module=dynamic 
      --with-http_realip_module 
      --with-http_secure_link_module 
      --with-http_slice_module 
      --with-http_ssl_module 
      --with-http_v2_module 
      --with-stream=dynamic 
      --with-stream_ssl_module 
      --with-google_perftools_module 
      --without-http_geo_module 
      --without-http_userid_module 
      --without-http_memcached_module 
      --without-http_split_clients_module 
      $(echo "$ExtModule")
      Check_Status
      
      make
      Check_Status
      
      Nginx_PATH="$(command -v nginx)"
      [ -n "$Nginx_PATH" ] || Check_Status
      [ -f "./objs/nginx" ] || Check_Status
      [ -f "$Nginx_PATH" ] && mv -f "${Nginx_PATH}" "${Nginx_PATH}.bak"
      cp -rf "./objs/nginx" "$Nginx_PATH"
      Check_Status
      
      mkdir -p /usr/local/share/man/man8
      cp -rf ./objs/nginx.8 /usr/local/share/man/man8/
      mandb
      
      rm -rf ./nginx*
      

       

夜河资源网提供的所有内容仅供学习与交流。通过使用本站内容随之而来的风险以及法律责任与本站无关,所承担的法律责任由使用者承担。
一、如果您发现本站侵害了相关版权,请附上本站侵权链接和您的版权证明一并发送至邮箱:yehes#qq.com(#替换为@)我们将会在五天内处理并断开该文章下载地址。
二、本站所有资源来自互联网整理收集,全部内容采用撰写共用版权协议,要求署名、非商业用途和相同方式共享,如转载请也遵循撰写共用协议。
三、根据署名-非商业性使用-相同方式共享 (by-nc-sa) 许可协议规定,只要他人在以原作品为基础创作的新作品上适用同一类型的许可协议,并且在新作品发布的显著位置,注明原作者的姓名、来源及其采用的知识共享协议,与该作品在本网站的原发地址建立链接,他人就可基于非商业目的对原作品重新编排、修改、节选或者本人的作品为基础进行创作和发布。
四、基于原作品创作的所有新作品都要适用同一类型的许可协议,因此适用该项协议, 对任何以他人原作为基础创作的作品自然同样都不得商业性用途。
五、根据二〇〇二年一月一日《计算机软件保护条例》规定:为了学习和研究软件内含的设计思想和原理,通过安装、显示、传输或者存储软件等方式使用软件的,可不经软件著作权人许可,无需向其支付报酬!
六、鉴此,也望大家按此说明转载和分享资源!本站提供的所有信息、教程、软件版权归原公司所有,仅供日常使用,不得用于任何商业用途,下载试用后请24小时内删除,因下载本站资源造成的损失,全部由使用者本人承担!