Skip to content

Instantly share code, notes, and snippets.

@ianwinter
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianwinter/3c1e4abee34e5428fa65 to your computer and use it in GitHub Desktop.
Save ianwinter/3c1e4abee34e5428fa65 to your computer and use it in GitHub Desktop.
nginx build options
#!/bin/bash
# Author: Ian Winter
# Warranty: None. Here be dragons and krakens.
# Base System: CentOS release 6.5 (Final)
# Notes: This is my own build sciprt, works for me - use at your own risk!
BUILD_DATE=`date +'%Y%m%d_%H%M%S'`
BUILD_BASE_PATH="/root/build_new"
BUILD_SRC_PATH="${BUILD_BASE_PATH}/src"
BUILD_CURRENT="${BUILD_BASE_PATH}/nginx/${BUILD_DATE}"
# build stuff
echo "making dirs"
mkdir -p ${BUILD_BASE_PATH} ${BUILD_SRC_PATH} ${BUILD_CURRENT}
echo "linking latest build"
ln -nfs ${BUILD_CURRENT} ${BUILD_BASE_PATH}/nginx/latest
## nginx core
### check http://nginx.org/en/download.html for the latest version
echo "processing nginx"
NGINX_VERSION=1.7.3
if [[ ! -f ${BUILD_SRC_PATH}/nginx-${NGINX_VERSION}.tar.gz ]]; then
echo ".. downloading"
wget -q http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz -O ${BUILD_SRC_PATH}/nginx-${NGINX_VERSION}.tar.gz
fi
echo ".. unpacking"
tar xfz ${BUILD_SRC_PATH}/nginx-${NGINX_VERSION}.tar.gz -C ${BUILD_CURRENT}
echo ".. done"
## pagespeed
NPS_VERSION=1.8.31.4
echo "processing pagespeed"
if [[ ! -f ${BUILD_SRC_PATH}/release-${NPS_VERSION}-beta.zip ]]; then
echo ".. downloading"
wget -q https://github.com/pagespeed/ngx_pagespeed/archive/release-${NPS_VERSION}-beta.zip -O ${BUILD_SRC_PATH}/release-${NPS_VERSION}-beta.zip
fi
echo ".. unpacking"
unzip -qq ${BUILD_SRC_PATH}/release-${NPS_VERSION}-beta.zip -d ${BUILD_CURRENT}
echo ".. done"
## psol
echo "processing psol"
PSOL_VERSION=1.7.30.4
if [[ ! -f ${BUILD_SRC_PATH}/${NPS_VERSION}.tar.gz ]]; then
echo ".. downloading"
wget -q https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}.tar.gz -O ${BUILD_SRC_PATH}/${NPS_VERSION}.tar.gz
fi
echo ".. unpacking"
tar xfz ${BUILD_SRC_PATH}/${NPS_VERSION}.tar.gz -C ${BUILD_CURRENT}/ngx_pagespeed-release-${NPS_VERSION}-beta
PAGESPEED_NGINX_DIR=${BUILD_CURRENT}/ngx_pagespeed-release-${NPS_VERSION}-beta/
echo ".. set ${PAGESPEED_NGINX_DIR}"
echo ".. done"
## pcre
echo "processing pcre"
PCRE_VERSION=8.35
if [[ ! -f ${BUILD_SRC_PATH}/pcre-${PCRE_VERSION}.tar.gz ]]; then
echo ".. downloading"
wget -q ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-${PCRE_VERSION}.tar.gz -O ${BUILD_SRC_PATH}/pcre-${PCRE_VERSION}.tar.gz
fi
echo ".. unpacking"
tar xfz ${BUILD_SRC_PATH}/pcre-${PCRE_VERSION}.tar.gz -C /usr/local/src/
PCRE_DIR=/usr/local/src/pcre-${PCRE_VERSION}
echo ".. set $PCRE_DIR"
echo ".. done"
## naxsi
echo "processing naxsi"
if [[ ! -f ${BUILD_SRC_PATH}/naxsi.zip ]]; then
echo ".. downloading"
wget -q https://github.com/nbs-system/naxsi/archive/master.zip -O ${BUILD_SRC_PATH}/naxsi.zip
fi
echo ".. unpacking"
unzip -qq ${BUILD_SRC_PATH}/naxsi.zip -d ${BUILD_CURRENT}
NAXSI_NGINX_DIR="${BUILD_CURRENT}/naxsi-master/naxsi_src"
echo ".. set ${NAXSI_NGINX_DIR}"
echo ".. done"
## passenger
echo "processing passenger"
#PASSENGER_NGINX_DIR=`passenger-config --root`/ext/nginx
PASSENGER_NGINX_DIR="/usr/local/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/passenger-4.0.44/ext/nginx"
echo "set ${PASSENGER_NGINX_DIR}"
echo ".. done"
## configure
echo "starting configure"
echo "moving to ${BUILD_CURRENT}/nginx-${NGINX_VERSION}"
cd ${BUILD_CURRENT}/nginx-${NGINX_VERSION}
./configure \
--conf-path=/etc/nginx/nginx.conf \
--add-module=${NAXSI_NGINX_DIR} \
--add-module=${PAGESPEED_NGINX_DIR} \
--add-module=${PASSENGER_NGINX_DIR} \
--prefix=/usr \
--pid-path=/var/run/nginx.pid \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/acces.log \
--http-client-body-temp-path=/var/cache/nginx/client_body_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 \
--with-http_ssl_module \
--with-http_gzip_static_module \
--with-http_addition_module \
--with-http_stub_status_module \
--with-pcre=$PCRE_DIR \
--without-mail_pop3_module \
--without-mail_imap_module \
--without-mail_smtp_module \
--without-http_uwsgi_module \
--without-http_scgi_module \
;
echo "configure complete"
echo "run 'cd ${BUILD_CURRENT}/nginx-${NGINX_VERSION} && make && make install'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment