|  | 
|  | 1 | +#!/bin/bash | 
|  | 2 | + | 
|  | 3 | +#Versions of Google's Pagespeed, NAXSI, NGINX. Along with other variables. | 
|  | 4 | +DIRECTORY=/root/webserver | 
|  | 5 | +#DO NOT add / at the end. | 
|  | 6 | +PAGESPEED=1.9.32.6 | 
|  | 7 | +NGINX=1.8.0 | 
|  | 8 | +NAXSI=0.54rc3 | 
|  | 9 | +COMPILE="--add-module=${DIRECTORY}/ngx_pagespeed-release-${PAGESPEED}-beta \ | 
|  | 10 | +--add-module=${DIRECTORY}/naxsi-${NAXSI}/naxsi_src \ | 
|  | 11 | +--without-mail_pop3_module \ | 
|  | 12 | +--without-mail_imap_module \ | 
|  | 13 | +--without-mail_smtp_module \ | 
|  | 14 | +--with-http_ssl_module \ | 
|  | 15 | +--with-http_spdy_module \ | 
|  | 16 | +--with-http_stub_status_module \ | 
|  | 17 | +--with-http_gzip_static_module" | 
|  | 18 | + | 
|  | 19 | +#Ensure dependencies of BUILD-ESSENTIAL ARE PRESENT | 
|  | 20 | +function dependencies () | 
|  | 21 | +{ | 
|  | 22 | +  sudo apt-get update | 
|  | 23 | +	sudo apt-get -y install sudo make wget build-essential zlib1g-dev libpcre3 libpcre3-dev unzip libssl-dev | 
|  | 24 | +} | 
|  | 25 | + | 
|  | 26 | +#Create directory if it is not present, and head to directory install | 
|  | 27 | +function folder-check-create () | 
|  | 28 | +{ | 
|  | 29 | +	if [ ! -d "${DIRECTORY}" ]; then | 
|  | 30 | +	    mkdir -p "${DIRECTORY}" | 
|  | 31 | +	fi | 
|  | 32 | + | 
|  | 33 | +	cd ${DIRECTORY} | 
|  | 34 | +} | 
|  | 35 | + | 
|  | 36 | +#Preparation of PAGESPEED | 
|  | 37 | +function prepare-pagespeed () | 
|  | 38 | +{ | 
|  | 39 | +	if [ ! -d ngx_pagespeed-release-${PAGESPEED}-beta ]; | 
|  | 40 | +		then | 
|  | 41 | +			rm -rf ngx_pagespeed-release-*-beta | 
|  | 42 | +			wget https://github.com/pagespeed/ngx_pagespeed/archive/release-${PAGESPEED}-beta.zip | 
|  | 43 | +			unzip release-${PAGESPEED}-beta.zip | 
|  | 44 | +			rm release-${PAGESPEED}-beta.zip | 
|  | 45 | + | 
|  | 46 | +			cd ngx_pagespeed-release-${PAGESPEED}-beta/ | 
|  | 47 | +			wget https://dl.google.com/dl/page-speed/psol/${PAGESPEED}.tar.gz | 
|  | 48 | +			tar -xzvf ${PAGESPEED}.tar.gz | 
|  | 49 | +			rm ${PAGESPEED}.tar.gz | 
|  | 50 | +		fi | 
|  | 51 | + | 
|  | 52 | +		#Go to install directory | 
|  | 53 | +		cd ${DIRECTORY} | 
|  | 54 | +	} | 
|  | 55 | + | 
|  | 56 | +#Preparation of NAXSI | 
|  | 57 | +function prepare-naxsi () | 
|  | 58 | +{ | 
|  | 59 | +if [ ! -d naxsi-${NAXSI} ]; | 
|  | 60 | +	then | 
|  | 61 | +		rm -rf naxsi-*; | 
|  | 62 | +		wget https://github.com/nbs-system/naxsi/archive/${NAXSI}.tar.gz; | 
|  | 63 | +		tar -xvzf ${NAXSI}.tar.gz; | 
|  | 64 | +		rm ${NAXSI}.tar.gz; | 
|  | 65 | +	fi; | 
|  | 66 | +} | 
|  | 67 | + | 
|  | 68 | +#Preparation of NGINX | 
|  | 69 | +function prepare-nginx () | 
|  | 70 | +{ | 
|  | 71 | +	if [ ! -d nginx-${NGINX} ]; | 
|  | 72 | +		then | 
|  | 73 | +			rm -rf nginx-*; | 
|  | 74 | +			wget http://nginx.org/download/nginx-${NGINX}.tar.gz; | 
|  | 75 | +			tar -xvzf nginx-${NGINX}.tar.gz; | 
|  | 76 | +			rm nginx-${NGINX}.tar.gz; | 
|  | 77 | +		fi; | 
|  | 78 | +} | 
|  | 79 | + | 
|  | 80 | +function compile () | 
|  | 81 | +{ | 
|  | 82 | +	cd ${DIRECTORY}/nginx-${NGINX} | 
|  | 83 | +	./configure ${COMPILE} | 
|  | 84 | +	make; | 
|  | 85 | +	sudo make install | 
|  | 86 | +} | 
|  | 87 | + | 
|  | 88 | + | 
|  | 89 | +#Execute functions | 
|  | 90 | + | 
|  | 91 | +dependencies | 
|  | 92 | +#Installs dependencies. Comment it out if you already have proper dependencies. | 
|  | 93 | +folder-check-create | 
|  | 94 | +#Creates install folder specified in DIRECTORY variable and enters the folder. | 
|  | 95 | +prepare-pagespeed | 
|  | 96 | +#Downloads, and unpacks NGX_PAGESPEED module | 
|  | 97 | +prepare-naxsi | 
|  | 98 | +#Downloads, and unpacks NAXSI_SRC module | 
|  | 99 | +prepare-nginx | 
|  | 100 | +#Compiles, and installs NGINX + MODULES with COMPILE | 
|  | 101 | +compile | 
0 commit comments