From de8084b4f704a47d0f90c568ff97c2d2c0e7b6a1 Mon Sep 17 00:00:00 2001 From: tianyu Date: Wed, 11 May 2016 11:39:24 +0800 Subject: [PATCH] Update upgrade-nginx.sh --- nginx/upgrade-nginx.sh | 68 +++++++++++++++++++++++++++++------------- 1 file changed, 48 insertions(+), 20 deletions(-) diff --git a/nginx/upgrade-nginx.sh b/nginx/upgrade-nginx.sh index e002cef..06531fa 100644 --- a/nginx/upgrade-nginx.sh +++ b/nginx/upgrade-nginx.sh @@ -1,10 +1,14 @@ #!/bin/bash VERSION="1.10.0" -OLD_VERSION=$(nginx -v 2>&1|cut -d '/' -f 2) -SSL_VERSION="1.0.2g" -ZLIB_VERSION="1.2.8" +if [ ! -z "$1" ];then + VERSION="$1" +fi + +echo "Start building nginx-$VERSION ..." + +OLD_VERSION=$(nginx -v 2>&1|cut -d '/' -f 2) cd || exit 1 @@ -17,28 +21,41 @@ mkdir nginx cd nginx || exit 1 # Download and extract nginx -wget http://nginx.org/download/nginx-$VERSION.tar.gz -tar xf nginx-$VERSION.tar.gz - -# Download and extract OpenSSL -wget https://www.openssl.org/source/openssl-$SSL_VERSION.tar.gz -tar xf openssl-$SSL_VERSION.tar.gz - -# Download and extract gzip -wget http://zlib.net/zlib-$ZLIB_VERSION.tar.gz -tar xf zlib-$ZLIB_VERSION.tar.gz +wget "http://nginx.org/download/nginx-$VERSION.tar.gz" +tar xf "nginx-$VERSION.tar.gz" # Delete downloads rm -- *.tar.gz +# Download ngx_http_auth_pam_module +git clone https://github.com/stogh/ngx_http_auth_pam_module \ +"nginx-$VERSION/modules/nginx-auth-pam" + +# Download nginx-dav-ext-module +git clone https://github.com/arut/nginx-dav-ext-module \ +"nginx-$VERSION/modules/nginx-dav-ext-module" + +# Download echo-nginx-module +git clone https://github.com/openresty/echo-nginx-module \ +"nginx-$VERSION/modules/nginx-echo" + +# Download nginx-upstream-fair +git clone https://github.com/gnosek/nginx-upstream-fair \ +"nginx-$VERSION/modules/nginx-upstream-fair" + # Download ngx_http_substitutions_filter_module -git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module +git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module \ +"nginx-$VERSION/modules/ngx_http_substitutions_filter_module" + +# Download nginx-module-vts +git clone https://github.com/vozlt/nginx-module-vts \ +"nginx-$VERSION/modules/nginx-module-vts" cd "nginx-$VERSION" || exit 1 ./configure \ ---with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' \ ---with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' \ +--with-cc-opt='-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' \ +--with-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now' \ --sbin-path=/usr/sbin/nginx \ --prefix=/usr/share/nginx \ --conf-path=/etc/nginx/nginx.conf \ @@ -57,23 +74,34 @@ cd "nginx-$VERSION" || exit 1 --with-http_ssl_module \ --with-http_stub_status_module \ --with-http_realip_module \ +--with-http_auth_request_module \ --with-http_addition_module \ --with-http_dav_module \ --with-http_geoip_module \ +--with-http_gunzip_module \ --with-http_gzip_static_module \ --with-http_image_filter_module \ --with-http_v2_module \ --with-http_sub_module \ --with-http_xslt_module \ +--with-stream \ +--with-stream_ssl_module \ --with-mail \ --with-mail_ssl_module \ ---with-http_sub_module \ ---with-zlib=../zlib-$ZLIB_VERSION \ ---with-openssl=../openssl-$SSL_VERSION \ ---add-module=../ngx_http_substitutions_filter_module +--with-threads \ +--add-module=modules/nginx-auth-pam \ +--add-module=modules/nginx-dav-ext-module \ +--add-module=modules/nginx-echo \ +--add-module=modules/nginx-upstream-fair \ +--add-module=modules/ngx_http_substitutions_filter_module \ +--add-module=modules/nginx-module-vts make +if [ "$?" -ne 0 ]; then + exit 1; +fi + echo "Stop service ..." service nginx stop cd /etc || exit 1