SHARE
TWEET

nginx-build.sh by nachash

a guest Nov 8th, 2014 5,445 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. # Depends: build-essential, unzip, the nginx build dependencies, and nginx's init script.
  3. # Easy way to get all the dependencies: apt-get install unzip nginx && apt-get remove nginx && apt-get build-dep nginx
  4. # Instructions: Run as root and supply a valid nginx version as an argument.
  5. # Example usage: ./nginx-build.sh 1.5.13
  6.  
  7. # This is for compiling with architecture-specific CFLAGS.
  8.  
  9. arch=$(uname -m)
  10.  
  11. # cd for super ultra maximum shell scripting security.
  12.  
  13. cd /root/
  14.  
  15. # Doing some basic clean-up because naxsi's archive always has the same filename.
  16.  
  17. rm -rf master.zip
  18. rm -rf naxsi-master/
  19.  
  20. # The next command downloads the latest version of naxsi, while the one after that downloads the specified nginx if you don't have it.
  21.  
  22. proxychains wget https://github.com/nbs-system/naxsi/archive/master.zip
  23. proxychains wget -nc http://nginx.org/download/nginx-$1.tar.gz
  24.  
  25. # Unpack everything
  26.  
  27. unzip master.zip
  28. tar -zxvf nginx-$1.tar.gz
  29.  
  30. # Time to cd into the nginx dir and run ./configure. Feel free to add or remove modules to suit your environment.
  31.  
  32. cd nginx-$1
  33. ./configure --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --add-module=../naxsi-master/naxsi_src --with-http_gzip_static_module --with-http_realip_module --without-http_auth_basic_module --without-http_empty_gif_module --without-http_geo_module --without-http_limit_req_module --without-http_limit_conn_module --without-http_map_module --without-http_proxy_module --without-http_referer_module --without-http_scgi_module --without-http_ssi_module --without-http_upstream_ip_hash_module --without-http_userid_module --without-http_uwsgi_module
  34.  
  35. # This is the fun part of the script.
  36.  
  37. if [ "$arch" = "i686" ]
  38. then
  39.         sed -i 's/-O/-Os -fstack-protector-all -fforce-addr -D_FORTIFY_SOURCES=2 -ffast-math -fomit-frame-pointer -falign-functions=32 -falign-loops=16/' objs/Makefile
  40.  
  41. elif [ "$arch" = "x86_64" ]
  42. then
  43.         sed -i 's/-O/-Os -fstack-protector-all -fforce-addr -D_FORTIFY_SOURCES=2 -ffast-math -fomit-frame-pointer -falign-functions=64 -falign-loops=32/' objs/Makefile
  44.  
  45. else
  46.         echo "Your architecture of choice is not currently supported by this script."
  47.         exit
  48. fi
  49.  
  50. # The moment of truth...
  51.  
  52. make install
  53.  
  54. # Just going to force-kill nginx and restart it. If nothing broke, you should be serving up pages once these commands finish.
  55.  
  56. fuser -k 80/tcp
  57. /etc/init.d/nginx restart
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top