Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Depends: build-essential, unzip, the nginx build dependencies, and nginx's init script.
- # Easy way to get all the dependencies: apt-get install unzip nginx && apt-get remove nginx && apt-get build-dep nginx
- # Instructions: Run as root and supply a valid nginx version as an argument.
- # Example usage: ./nginx-build.sh 1.5.13
- # This is for compiling with architecture-specific CFLAGS.
- arch=$(uname -m)
- # cd for super ultra maximum shell scripting security.
- cd /root/
- # Doing some basic clean-up because naxsi's archive always has the same filename.
- rm -rf master.zip
- rm -rf naxsi-master/
- # The next command downloads the latest version of naxsi, while the one after that downloads the specified nginx if you don't have it.
- proxychains wget https://github.com/nbs-system/naxsi/archive/master.zip
- proxychains wget -nc http://nginx.org/download/nginx-$1.tar.gz
- # Unpack everything
- unzip master.zip
- tar -zxvf nginx-$1.tar.gz
- # Time to cd into the nginx dir and run ./configure. Feel free to add or remove modules to suit your environment.
- cd nginx-$1
- ./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
- # This is the fun part of the script.
- if [ "$arch" = "i686" ]
- then
- 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
- elif [ "$arch" = "x86_64" ]
- then
- 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
- else
- echo "Your architecture of choice is not currently supported by this script."
- exit
- fi
- # The moment of truth...
- make install
- # Just going to force-kill nginx and restart it. If nothing broke, you should be serving up pages once these commands finish.
- fuser -k 80/tcp
- /etc/init.d/nginx restart
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement