Pulling nginx from source, customizing & auto updating across servers is a pain, We use pagespeed & custom header modules across all our servers, it autominifies resources & increases page performance without giving pain.
Below is script we use :
#!/bin/bash
NGNX_VER=1.11.1
OPENSSL_VER=1.0.2i
NPS_VERSION=1.11.33.3
#install dependecies
suod apt-get install libpcre3 libpcre3-dev checkinstall zlib1g-dev -y
sudo apt-get build-dep nginx -y
#download nginx
wget http://nginx.org/download/nginx-${NGNX_VER}.tar.gz
tar zxf nginx-${NGNX_VER}.tar.gz
cd nginx-${NGNX_VER}
#pagespeed module
wget https://github.com/pagespeed/ngx_pagespeed/archive/release-${NPS_VERSION}-beta.zip -O release-${NPS_VERSION}-beta.zip
unzip release-${NPS_VERSION}-beta.zip
cd ngx_pagespeed-release-${NPS_VERSION}-beta/
wget https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}.tar.gz
tar -xzvf ${NPS_VERSION}.tar.gz # extracts to psol/
cd ..
#download openssl
wget https://www.openssl.org/source/openssl-${OPENSSL_VER}.tar.gz
tar -xzvf openssl-${OPENSSL_VER}.tar.gz
# not using this because it uses dev releases/
#git clone https://github.com/openssl/openssl.git
git clone https://github.com/FRiCKLE/ngx_cache_purge.git
git clone git://github.com/alibaba/nginx-http-concat.git
git clone https://github.com/openresty/headers-more-nginx-module.git
#configure
./configure --prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
--user=www-data \
--group=www-data \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_sub_module \
--with-mail \
--with-mail_ssl_module \
--with-http_v2_module \
--with-file-aio \
--with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2' \
--with-ld-opt='-Wl,-z,relro -Wl,--as-needed' \
--with-ipv6 \
--with-debug \
--with-openssl=openssl-${OPENSSL_VER} \
--add-module=ngx_pagespeed-release-${NPS_VERSION}-beta/ \
--add-module=ngx_cache_purge \
--add-module=nginx-http-concat \
--add-module=headers-more-nginx-module
#compile
make
#build package
checkinstall --install=no -y
To reduce pain of updating we put it on cdn http://cdn.tik.co/s/general(custom_nginx).sh which can be used as
curl -S "cdn.tik.co/s/general(custom_nginx).sh" | bash
Recent Comments