HansVanEijsden

NGINX build script

Dec 8th, 2016
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.41 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Variabelen, geef hier de versie in, OpenSSL moet al klaargemaakt zijn
  4. NGINXV="1.11.9"
  5. OPENSSLV="1.0.2j"
  6. NPS_VERSION="1.12.34.1"
  7.  
  8. # Pagespeed voorbereiden
  9. cd
  10. rm -f release-${NPS_VERSION}-beta.zip
  11. rm -rf ngx_pagespeed-${NPS_VERSION}-beta/
  12. wget https://github.com/pagespeed/ngx_pagespeed/archive/v${NPS_VERSION}-beta.zip -O release-${NPS_VERSION}-beta.zip
  13. unzip release-${NPS_VERSION}-beta.zip
  14. cd ngx_pagespeed-${NPS_VERSION}-beta/
  15. wget https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}-x64.tar.gz
  16. tar -xzvf ${NPS_VERSION}-x64.tar.gz  # extracts to psol/
  17.  
  18. # Systeemvariabelen
  19. PATH=/usr/lib/ccache:$PATH
  20. DEB_CFLAGS_SET="-O3 -march=native -flto -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security"
  21. DEB_CXXFLAGS_SET="-O3 -march=native -flto -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security"
  22. DEB_FFLAGS_SET="-O3"
  23. DEB_LDFLAGS_SET="-Wl,-z,relro -flto"
  24.  
  25. # De Git sources bijwerken
  26. sudo rm -rf /usr/local/src/ngx_brotli_module
  27. git clone --recursive https://github.com/cloudflare/ngx_brotli_module.git /usr/local/src/ngx_brotli_module
  28.  
  29. # Downloaden, uitpakken en opschonen sources
  30. cd /usr/local/src
  31. curl -o nginx.tar.gz http://nginx.org/download/nginx-$NGINXV.tar.gz
  32. tar -zxf nginx.tar.gz
  33. rm -f nginx.tar.gz
  34. cd /usr/local/src/nginx-$NGINXV
  35. make clean
  36.  
  37. # Patchen sources
  38. curl -O "https://raw.githubusercontent.com/cloudflare/sslconfig/master/patches/nginx__1.11.5_dynamic_tls_records.patch"
  39. patch -p1 < nginx__1.11.5_dynamic_tls_records.patch
  40.  
  41. # Configureren
  42. ./configure \
  43. --add-module=/usr/local/src/ngx_brotli_module \
  44. --add-module=$HOME/ngx_pagespeed-${NPS_VERSION}-beta \
  45. --prefix=/opt/nginx \
  46. --user=www-data \
  47. --group=www-data \
  48. --with-http_ssl_module \
  49. --with-http_v2_module \
  50. --with-openssl=/usr/local/src/openssl-$OPENSSLV \
  51. --with-openssl-opt="enable-ec_nistp_64_gcc_128 threads" \
  52. --with-pcre-jit \
  53. --with-file-aio \
  54. --with-http_flv_module \
  55. --with-http_geoip_module \
  56. --with-http_gunzip_module \
  57. --with-http_mp4_module \
  58. --with-http_realip_module \
  59. --with-http_stub_status_module \
  60. --with-threads \
  61. --with-cc-opt="-DTCP_FASTOPEN=23 -O3 -march=native -flto" \
  62. --with-ld-opt="-DTCP_FASTOPEN=23 -O3 -march=native -flto"
  63.  
  64. # Installeren en opschonen
  65. sudo nice make install
  66. rm -rf /usr/local/src/nginx-$NGINXV
  67.  
  68. # Vergeet niet de service te herstarten
  69. echo "Vergeet niet de services te herstarten: sudo systemctl restart memcached nginx"
Add Comment
Please, Sign In to add comment