Instantly share code, notes, and snippets.

Embed
What would you like to do?
Building NGINX on Ubuntu & Debian
## Change to NGINX sources
cd /usr/src/nginx_source/nginx-*
## Patch NGINX build config by adding
## both Google PageSpeed and Dav Ext modules
sed -i "s|--with-http_auth_request_module --with|\
--with-http_auth_request_module --add-module=/usr/src/incubator-pagespeed-ngx-${ngx_pagespeed_ver}-${ngx_pagespeed_rel} --with|" \
./debian/rules
sed -i "s|--with-http_dav_module --with|\
--with-http_dav_module --add-module=/usr/src/nginx-dav-ext-module-${ngx_ext_dav_ver} --with|" \
./debian/rules
## Build .deb package(s)
dpkg-buildpackage -b
## Go to parent folder and install .deb package
cd ..
dpkg -i nginx_*deb
export ngx_pagespeed_ver=1.13.35.2
export ngx_pagespeed_rel=stable
export ngx_ext_dav_ver=0.1.0
cd /usr/src
## Download and extract Google Pagespeed NGINX module
wget https://github.com/pagespeed/ngx_pagespeed/archive/v${ngx_pagespeed_ver}-${ngx_pagespeed_rel}.tar.gz
tar xvfz v${ngx_pagespeed_ver}-${ngx_pagespeed_rel}.tar.gz
## Download and extract PageSpeed Optimization Libraries
cd incubator-pagespeed-ngx-${ngx_pagespeed_ver}-${ngx_pagespeed_rel}/
psol_url=https://dl.google.com/dl/page-speed/psol/${ngx_pagespeed_ver}.tar.gz
psol_url=$(scripts/format_binary_url.sh PSOL_BINARY_URL)
wget ${psol_url}
tar -xzvf ${ngx_pagespeed_ver}*.tar.gz
cd /usr/src
## Download DAV Ext NGINX module
## !! Remove this if you don't need dav ext module or replace with modules _you_ need
wget https://github.com/arut/nginx-dav-ext-module/archive/v${ngx_ext_dav_ver}.tar.gz
tar xzvf v${ngx_ext_dav_ver}.tar.gz
## Add NGINX repo
source /etc/os-release
echo "deb http://nginx.org/packages/${ID}/ ${VERSION_CODENAME} nginx" | tee /etc/apt/sources.list.d/nginx.list
echo "deb-src http://nginx.org/packages/${ID}/ ${VERSION_CODENAME} nginx" | tee -a /etc/apt/sources.list.d/nginx.list
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 ABF5BD827BD9BF62
## Refresh APT catalog
rm -rf /var/lib/apt/lists/*
sed -i "s|# deb-src|deb-src|" /etc/apt/sources.list
apt-get update
## Download NGINX sources and its build dependencies
mkdir -p /usr/src/nginx_source/
cd /usr/src/nginx_source/
apt-get source nginx
apt-get install -qy tar wget dpkg-dev \
libgd-dev libgeoip-dev libhiredis-dev libluajit-5.1-dev \
libmhash-dev libpam0g-dev libperl-dev libxslt1-dev
apt-get build-dep nginx -qy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment