Skip to content

Instantly share code, notes, and snippets.

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|" \
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|" \
## Build .deb package(s)
dpkg-buildpackage -b
## Go to parent folder and install .deb package
cd ..
dpkg -i nginx_*deb
export ngx_pagespeed_ver=
export ngx_pagespeed_rel=stable
export ngx_ext_dav_ver=0.1.0
cd /usr/src
## Download and extract Google Pagespeed NGINX module
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=$(scripts/ 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
tar xzvf v${ngx_ext_dav_ver}.tar.gz
## Add NGINX repo
source /etc/os-release
echo "deb${ID}/ ${VERSION_CODENAME} nginx" | tee /etc/apt/sources.list.d/nginx.list
echo "deb-src${ID}/ ${VERSION_CODENAME} nginx" | tee -a /etc/apt/sources.list.d/nginx.list
apt-key adv --recv-keys --keyserver hkp:// 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 \
libssl-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
You can’t perform that action at this time.