#!/bin/bash version=$1 if [ ! -n "$version" ];then read -p "Enter or press the Enter key to use the latest version: " version fi apt-get install -y wget curl gcc g++ make git libssl-dev libpcre3-dev libjemalloc2 libjemalloc-dev libexpat1-dev zlib1g-dev libxml2-dev libxslt1-dev libgeoip-dev libmaxminddb-dev cmake if [ ! -n "$version" ];then version=`curl -s https://api.github.com/repos/nginx/nginx/tags?per_page=5|grep tarball_url|head -1|awk -F "\"" '{print $4}'|awk -F "-" '{print $2}'` fi cd /tmp nginx="nginx-${version}"; nginx_file=${nginx}.tar.gz url="http://nginx.org/download/${nginx_file}" wget -c $url; if [ ! -f "$nginx_file" ];then echo "Download faild!" exit -1; fi rm -rf ${nginx} tar axf ${nginx_file} echo "Extract nginx done" cd ${nginx} git clone https://github.com/arut/nginx-dav-ext-module.git git clone https://github.com/alibaba/nginx-http-concat.git git clone https://github.com/openresty/echo-nginx-module.git #git clone https://github.com/cuber/ngx_http_google_filter_module.git git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module.git git clone https://github.com/FRiCKLE/ngx_cache_purge.git git clone https://github.com/google/ngx_brotli.git git clone https://github.com/openresty/headers-more-nginx-module.git git clone https://github.com/leev/ngx_http_geoip2_module.git git clone https://github.com/vozlt/nginx-module-vts.git cd ngx_brotli && git submodule update --init && cd deps/brotli mkdir out && cd out cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS="-Ofast -m64 -march=native -mtune=native -flto -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections" -DCMAKE_CXX_FLAGS="-Ofast -m64 -march=native -mtune=native -flto -funroll-loops -ffunction-sections -fdata-sections -Wl,--gc-sections" -DCMAKE_INSTALL_PREFIX=./installed .. cmake --build . --config Release --target brotlienc cd ../../../.. cd /tmp/${nginx} ./configure --prefix=/opt/nginx --pid-path=/var/run/nginx.pid --with-http_secure_link_module --with-http_realip_module --with-http_sub_module --with-http_dav_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_addition_module --with-http_ssl_module --with-http_v2_module --with-http_slice_module --with-http_mp4_module --with-http_flv_module --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-stream_realip_module --with-pcre --with-ld-opt="-ljemalloc" --add-module=nginx-http-concat --add-module=echo-nginx-module --add-module=ngx_http_substitutions_filter_module --add-module=nginx-dav-ext-module --add-module=ngx_cache_purge --add-module=ngx_brotli --add-module=headers-more-nginx-module --with-threads --with-http_geoip_module --add-module=ngx_http_geoip2_module --add-module=nginx-module-vts make || exit if [ ! -f "/opt/nginx/sbin/nginx" ];then make install echo "Install nginx done" else mv /opt/nginx/sbin/nginx{,.bak} -f cp ./objs/nginx /opt/nginx/sbin/nginx make upgrade echo "Upgrade nginx done" fi exit 0;