Last active
August 29, 2015 14:00
-
-
Save alainwolf/11267280 to your computer and use it in GitHub Desktop.
Install Nginx from source with pagespeed and cache_purge modules in Ubuntu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Install Nginx from source with pagespeed and cache_purge modules in Ubuntu | |
# | |
# Add the official nginx.org 'mainline' (development) Ubuntu package repository | |
sudo -s | |
echo "deb http://nginx.org/packages/mainline/ubuntu/ `lsb_release -sc` nginx" \ | |
> /etc/apt/sources.list.d/nginx.org-mainline.list | |
echo "deb-src http://nginx.org/packages/mainline/ubuntu/ `lsb_release -sc` nginx" \ | |
>> /etc/apt/sources.list.d/nginx.org-mainline.list | |
exit | |
# | |
# Add the nginx.org package signing key to the systems trusted packages keyring | |
wget -O - http://nginx.org/keys/nginx_signing.key | sudo apt-key add - | |
# | |
# Add the nginx.org package signing key to our personal trusted packages keyring | |
wget -O - http://nginx.org/keys/nginx_signing.key | \ | |
gpg --no-default-keyring --keyring ~/.gnupg/trustedkeys.gpg --import - | |
# | |
# Update the list of package | |
sudo apt-get update | |
# | |
# Get essential stuff needed for building packages in general | |
sudo apt-get install build-essential unzip dpkg-sig | |
# | |
# Get all the stuff needed for building the nginx package | |
sudo apt-get build-dep nginx | |
# | |
# Prepare source code directory | |
sudo mkdir -p /usr/local/src | |
sudo chown $USER /usr/local/src | |
sudo chmod u+rwx /usr/local/src | |
cd /usr/local/src | |
# | |
# Get the nginx package source code | |
apt-get source nginx | |
# | |
# Download the source code for the ngx_cache_purge module | |
wget -O ngx_cache_purge-2.1.zip https://github.com/FRiCKLE/ngx_cache_purge/archive/2.1.zip | |
unzip ngx_cache_purge-2.1.zip | |
# | |
# Download the source code for the Google pagespeed module | |
wget -O ngx_pagespeed-v1.7.30.4-beta https://github.com/pagespeed/ngx_pagespeed/archive/v1.7.30.4-beta.zip | |
unzip ngx_pagespeed-v1.7.30.4-beta | |
cd ngx_pagespeed-1.7.30.4-beta/ | |
wget https://dl.google.com/dl/page-speed/psol/1.7.30.4.tar.gz | |
tar -xzvf 1.7.30.4.tar.gz | |
cd .. | |
# | |
# Configure | |
sensible-editor /usr/local/src/nginx-1.7.0/debian/rules | |
# | |
# Add the following lines add the end of every "./configure" command | |
# ... \ | |
# --add-module=/usr/local/src/ngx_pagespeed-1.7.30.4-beta \ | |
# --add-module=/usr/local/src/ngx_cache_purge-2.1 | |
# | |
# Build our customized backport package | |
cd nginx-1.7.0 | |
dpkg-buildpackage -rfakeroot -uc -b | |
cd .. | |
# | |
# Install | |
sudo dpkg --install nginx_1.7.0-1~trusty_amd64.deb | |
# Prevent updates to overwrite our backport | |
sudo apt-mark hold nginx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment