Skip to content

Instantly share code, notes, and snippets.

@amoshydra
Forked from MattWilcox/build_nginx.sh
Created December 11, 2016 05:42

Revisions

  1. amoshydra revised this gist Dec 11, 2016. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions build_nginx.sh
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,9 @@
    #!/usr/bin/env bash

    # names of latest versions of each package
    export VERSION_PCRE=pcre-8.38
    export VERSION_OPENSSL=openssl-1.0.2d
    export VERSION_NGINX=nginx-1.9.7
    export VERSION_PCRE=pcre-8.39
    export VERSION_OPENSSL=openssl-1.1.0c
    export VERSION_NGINX=nginx-1.10.2

    # URLs to the source directories
    export SOURCE_OPENSSL=https://www.openssl.org/source/
  2. @MattWilcox MattWilcox revised this gist Dec 7, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion build_nginx.sh
    Original file line number Diff line number Diff line change
    @@ -42,7 +42,7 @@ cd $BPATH/$VERSION_OPENSSL
    rm -rf "$STATICLIBSSL"
    mkdir "$STATICLIBSSL"
    make clean
    ./config --prefix=$STATICLIBSSL no-shared enable-ec_nistp_64_gcc_128 \
    ./config --prefix=$STATICLIBSSL no-shared \
    && make depend \
    && make \
    && make install_sw
  3. @MattWilcox MattWilcox revised this gist Nov 25, 2015. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion build_nginx.sh
    Original file line number Diff line number Diff line change
    @@ -62,7 +62,6 @@ mkdir -p $BPATH/nginx
    --http-log-path=/var/log/nginx/access.log \
    --with-pcre=$BPATH/$VERSION_PCRE \
    --with-http_ssl_module \
    --with-http_spdy_module \
    --with-http_v2_module \
    --with-file-aio \
    --with-ipv6 \
  4. @MattWilcox MattWilcox revised this gist Nov 25, 2015. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions build_nginx.sh
    Original file line number Diff line number Diff line change
    @@ -63,6 +63,7 @@ mkdir -p $BPATH/nginx
    --with-pcre=$BPATH/$VERSION_PCRE \
    --with-http_ssl_module \
    --with-http_spdy_module \
    --with-http_v2_module \
    --with-file-aio \
    --with-ipv6 \
    --with-http_gzip_static_module \
  5. @MattWilcox MattWilcox revised this gist Nov 25, 2015. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions build_nginx.sh
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,9 @@
    #!/usr/bin/env bash

    # names of latest versions of each package
    export VERSION_PCRE=pcre-8.37
    export VERSION_OPENSSL=openssl-1.0.2a
    export VERSION_NGINX=nginx-1.9.0
    export VERSION_PCRE=pcre-8.38
    export VERSION_OPENSSL=openssl-1.0.2d
    export VERSION_NGINX=nginx-1.9.7

    # URLs to the source directories
    export SOURCE_OPENSSL=https://www.openssl.org/source/
  6. @MattWilcox MattWilcox revised this gist May 18, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions build_nginx.sh
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,9 @@
    #!/usr/bin/env bash

    # names of latest versions of each package
    export VERSION_PCRE=pcre-8.36
    export VERSION_PCRE=pcre-8.37
    export VERSION_OPENSSL=openssl-1.0.2a
    export VERSION_NGINX=nginx-1.7.10
    export VERSION_NGINX=nginx-1.9.0

    # URLs to the source directories
    export SOURCE_OPENSSL=https://www.openssl.org/source/
  7. @MattWilcox MattWilcox revised this gist Mar 21, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion build_nginx.sh
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ export SOURCE_PCRE=ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
    export SOURCE_NGINX=http://nginx.org/download/

    # make a 'today' variable for use in back-up filenames later
    today=$(date +"_%Y-%m-%d")
    today=$(date +"%Y-%m-%d")

    # clean out any files from previous runs of this script
    rm -rf build
  8. @MattWilcox MattWilcox revised this gist Mar 21, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion build_nginx.sh
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ export SOURCE_PCRE=ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
    export SOURCE_NGINX=http://nginx.org/download/

    # make a 'today' variable for use in back-up filenames later
    today=$(date +"%Y_%m_%d")
    today=$(date +"_%Y-%m-%d")

    # clean out any files from previous runs of this script
    rm -rf build
  9. @MattWilcox MattWilcox revised this gist Mar 21, 2015. 1 changed file with 12 additions and 23 deletions.
    35 changes: 12 additions & 23 deletions build_nginx.sh
    Original file line number Diff line number Diff line change
    @@ -2,16 +2,20 @@

    # names of latest versions of each package
    export VERSION_PCRE=pcre-8.36
    export VERSION_OPENSSL=openssl-1.0.1k
    export VERSION_NGINX=nginx-1.7.9
    export VERSION_OPENSSL=openssl-1.0.2a
    export VERSION_NGINX=nginx-1.7.10

    # URLs to the source directories for each package
    # URLs to the source directories
    export SOURCE_OPENSSL=https://www.openssl.org/source/
    export SOURCE_PCRE=ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
    export SOURCE_NGINX=http://nginx.org/download/

    # make a 'today' variable for use in back-up filenames later
    today=$(date +"%Y_%m_%d")

    # clean out any files from previous runs of this script
    rm -rf build
    rm -rf /etc/nginx-default
    mkdir build

    # ensure that we have the required software to compile our own nginx
    @@ -43,20 +47,8 @@ make clean
    && make \
    && make install_sw

    # remove the old default nginx config directories generated by previous runs of this script
    rm -rf /etc/nginx-default

    # remove the legacy back-up config created by previous runs of this script
    rm -rf /etc/nginx-bk-legacy

    # make the current 'backup' nginx config the legacy backup config
    mv /etc/nginx-bk /etc/nginx-bk-legacy

    # stop nginx server
    /etc/init.d/nginx stop

    # make the current live nginx the new back-up nginx
    mv /etc/nginx /etc/nginx-bk
    # rename the existing /etc/nginx directory so it's saved as a back-up
    mv /etc/nginx /etc/nginx-$today

    # build nginx, with various modules included/excluded
    cd $BPATH/$VERSION_NGINX
    @@ -80,14 +72,11 @@ mkdir -p $BPATH/nginx
    --without-mail_imap_module \
    && make && make install

    # rename the compiled default /etc/nginx directory so its accessible as a reference to the new nginx defaults
    # rename the compiled 'default' /etc/nginx directory so its accessible as a reference to the new nginx defaults
    mv /etc/nginx /etc/nginx-default

    # now restore /etc/nginx-bk to /etc/nginx so the old configuration is kept
    mv /etc/nginx-bk /etc/nginx

    # start nginx server
    /etc/init.d/nginx start
    # now restore the previous version of /etc/nginx to /etc/nginx so the old settings are kept
    mv /etc/nginx-$today /etc/nginx

    echo "All done.";
    echo "This build has not edited your existing /etc/nginx directory.";
  10. @MattWilcox MattWilcox revised this gist Jan 14, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions build_nginx.sh
    Original file line number Diff line number Diff line change
    @@ -2,8 +2,8 @@

    # names of latest versions of each package
    export VERSION_PCRE=pcre-8.36
    export VERSION_OPENSSL=openssl-1.0.1j
    export VERSION_NGINX=nginx-1.7.7
    export VERSION_OPENSSL=openssl-1.0.1k
    export VERSION_NGINX=nginx-1.7.9

    # URLs to the source directories for each package
    export SOURCE_OPENSSL=https://www.openssl.org/source/
  11. @MattWilcox MattWilcox revised this gist Oct 30, 2014. 1 changed file with 18 additions and 5 deletions.
    23 changes: 18 additions & 5 deletions build_nginx.sh
    Original file line number Diff line number Diff line change
    @@ -3,9 +3,9 @@
    # names of latest versions of each package
    export VERSION_PCRE=pcre-8.36
    export VERSION_OPENSSL=openssl-1.0.1j
    export VERSION_NGINX=nginx-1.7.6
    export VERSION_NGINX=nginx-1.7.7

    # URLs to the source directories
    # URLs to the source directories for each package
    export SOURCE_OPENSSL=https://www.openssl.org/source/
    export SOURCE_PCRE=ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
    export SOURCE_NGINX=http://nginx.org/download/
    @@ -43,9 +43,19 @@ make clean
    && make \
    && make install_sw

    # rename the existing /etc/nginx directory so it's saved as a back-up
    # remove the old default nginx config directories generated by previous runs of this script
    rm -rf /etc/nginx-default

    # remove the legacy back-up config created by previous runs of this script
    rm -rf /etc/nginx-bk-legacy

    # make the current 'backup' nginx config the legacy backup config
    mv /etc/nginx-bk /etc/nginx-bk-legacy

    # stop nginx server
    /etc/init.d/nginx stop

    # make the current live nginx the new back-up nginx
    mv /etc/nginx /etc/nginx-bk

    # build nginx, with various modules included/excluded
    @@ -70,12 +80,15 @@ mkdir -p $BPATH/nginx
    --without-mail_imap_module \
    && make && make install

    # rename the compiled /etc/nginx directory so its accessible as a reference to the new nginx defaults
    # rename the compiled default /etc/nginx directory so its accessible as a reference to the new nginx defaults
    mv /etc/nginx /etc/nginx-default

    # now restore the /etc/nginx-bk to /etc/nginx so the old settings are kept
    # now restore /etc/nginx-bk to /etc/nginx so the old configuration is kept
    mv /etc/nginx-bk /etc/nginx

    # start nginx server
    /etc/init.d/nginx start

    echo "All done.";
    echo "This build has not edited your existing /etc/nginx directory.";
    echo "If things aren't working now you may need to refer to the";
  12. @MattWilcox MattWilcox revised this gist Oct 21, 2014. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions build_nginx.sh
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,9 @@
    #!/usr/bin/env bash

    # names of latest versions of each package
    export VERSION_PCRE=pcre-8.35
    export VERSION_OPENSSL=openssl-1.0.1i
    export VERSION_NGINX=nginx-1.7.4
    export VERSION_PCRE=pcre-8.36
    export VERSION_OPENSSL=openssl-1.0.1j
    export VERSION_NGINX=nginx-1.7.6

    # URLs to the source directories
    export SOURCE_OPENSSL=https://www.openssl.org/source/
    @@ -44,6 +44,8 @@ make clean
    && make install_sw

    # rename the existing /etc/nginx directory so it's saved as a back-up
    rm -rf /etc/nginx-bk-legacy
    mv /etc/nginx-bk /etc/nginx-bk-legacy
    mv /etc/nginx /etc/nginx-bk

    # build nginx, with various modules included/excluded
  13. @MattWilcox MattWilcox revised this gist Aug 10, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion build_nginx.sh
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    # names of latest versions of each package
    export VERSION_PCRE=pcre-8.35
    export VERSION_OPENSSL=openssl-1.0.1i
    export VERSION_NGINX=nginx-1.7.3
    export VERSION_NGINX=nginx-1.7.4

    # URLs to the source directories
    export SOURCE_OPENSSL=https://www.openssl.org/source/
  14. @MattWilcox MattWilcox revised this gist Aug 10, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions build_nginx.sh
    Original file line number Diff line number Diff line change
    @@ -2,8 +2,8 @@

    # names of latest versions of each package
    export VERSION_PCRE=pcre-8.35
    export VERSION_OPENSSL=openssl-1.0.1h
    export VERSION_NGINX=nginx-1.7.1
    export VERSION_OPENSSL=openssl-1.0.1i
    export VERSION_NGINX=nginx-1.7.3

    # URLs to the source directories
    export SOURCE_OPENSSL=https://www.openssl.org/source/
  15. @MattWilcox MattWilcox revised this gist Jun 5, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions build_nginx.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    # names of latest versions of each package
    export VERSION_PCRE=pcre-8.35
    export VERSION_OPENSSL=openssl-1.0.1g
    export VERSION_OPENSSL=openssl-1.0.1h
    export VERSION_NGINX=nginx-1.7.1

    # URLs to the source directories
    @@ -15,7 +15,7 @@ rm -rf build
    mkdir build

    # ensure that we have the required software to compile our own nginx
    sudo apt-get -y install curl wget build-essential
    apt-get -y install curl wget build-essential

    # grab the source files
    wget -P ./build $SOURCE_PCRE$VERSION_PCRE.tar.gz
  16. @MattWilcox MattWilcox renamed this gist May 28, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  17. @MattWilcox MattWilcox revised this gist May 28, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    # names of latest versions of each package
    export VERSION_PCRE=pcre-8.35
    export VERSION_OPENSSL=openssl-1.0.1g
    export VERSION_NGINX=nginx-1.7.0
    export VERSION_NGINX=nginx-1.7.1

    # URLs to the source directories
    export SOURCE_OPENSSL=https://www.openssl.org/source/
  18. @MattWilcox MattWilcox created this gist May 24, 2014.
    81 changes: 81 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,81 @@
    #!/usr/bin/env bash

    # names of latest versions of each package
    export VERSION_PCRE=pcre-8.35
    export VERSION_OPENSSL=openssl-1.0.1g
    export VERSION_NGINX=nginx-1.7.0

    # URLs to the source directories
    export SOURCE_OPENSSL=https://www.openssl.org/source/
    export SOURCE_PCRE=ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
    export SOURCE_NGINX=http://nginx.org/download/

    # clean out any files from previous runs of this script
    rm -rf build
    mkdir build

    # ensure that we have the required software to compile our own nginx
    sudo apt-get -y install curl wget build-essential

    # grab the source files
    wget -P ./build $SOURCE_PCRE$VERSION_PCRE.tar.gz
    wget -P ./build $SOURCE_OPENSSL$VERSION_OPENSSL.tar.gz --no-check-certificate
    wget -P ./build $SOURCE_NGINX$VERSION_NGINX.tar.gz

    # expand the source files
    cd build
    tar xzf $VERSION_NGINX.tar.gz
    tar xzf $VERSION_OPENSSL.tar.gz
    tar xzf $VERSION_PCRE.tar.gz
    cd ../

    # set where OpenSSL and nginx will be built
    export BPATH=$(pwd)/build
    export STATICLIBSSL="$BPATH/staticlibssl"

    # build static openssl
    cd $BPATH/$VERSION_OPENSSL
    rm -rf "$STATICLIBSSL"
    mkdir "$STATICLIBSSL"
    make clean
    ./config --prefix=$STATICLIBSSL no-shared enable-ec_nistp_64_gcc_128 \
    && make depend \
    && make \
    && make install_sw

    # rename the existing /etc/nginx directory so it's saved as a back-up
    mv /etc/nginx /etc/nginx-bk

    # build nginx, with various modules included/excluded
    cd $BPATH/$VERSION_NGINX
    mkdir -p $BPATH/nginx
    ./configure --with-cc-opt="-I $STATICLIBSSL/include -I/usr/include" \
    --with-ld-opt="-L $STATICLIBSSL/lib -Wl,-rpath -lssl -lcrypto -ldl -lz" \
    --sbin-path=/usr/sbin/nginx \
    --conf-path=/etc/nginx/nginx.conf \
    --pid-path=/var/run/nginx.pid \
    --error-log-path=/var/log/nginx/error.log \
    --http-log-path=/var/log/nginx/access.log \
    --with-pcre=$BPATH/$VERSION_PCRE \
    --with-http_ssl_module \
    --with-http_spdy_module \
    --with-file-aio \
    --with-ipv6 \
    --with-http_gzip_static_module \
    --with-http_stub_status_module \
    --without-mail_pop3_module \
    --without-mail_smtp_module \
    --without-mail_imap_module \
    && make && make install

    # rename the compiled /etc/nginx directory so its accessible as a reference to the new nginx defaults
    mv /etc/nginx /etc/nginx-default

    # now restore the /etc/nginx-bk to /etc/nginx so the old settings are kept
    mv /etc/nginx-bk /etc/nginx

    echo "All done.";
    echo "This build has not edited your existing /etc/nginx directory.";
    echo "If things aren't working now you may need to refer to the";
    echo "configuration files the new nginx ships with as defaults,";
    echo "which are available at /etc/nginx-default";