Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cybersholt/6e0906cebacaeb897dcd05428533d40d to your computer and use it in GitHub Desktop.
Save cybersholt/6e0906cebacaeb897dcd05428533d40d to your computer and use it in GitHub Desktop.
How to Install Nginx and Google PageSpeed on Debian/Ubuntu
#!/bin/bash
## Install PageSpeed on Ubuntu 16.04
## https://www.howtoforge.com/tutorial/how-to-install-nginx-and-google-pagespeed-on-ubuntu-16-04/
## https://github.com/pagespeed/ngx_pagespeed/releases
## https://developers.google.com/speed/pagespeed/module/
## https://blog.zimbra.com/2017/09/tech-center-now-17x-times-faster/
## Run as root (sudo su)
NPS_VERSION=1.12.34.3-stable
NPS_RELEASE_NUMBER=${NPS_VERSION/stable/}
echo "deb http://nginx.org/packages/ubuntu/ xenial nginx
deb-src http://nginx.org/packages/ubuntu/ xenial nginx" > /etc/apt/sources.list.d/nginx.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ABF5BD827BD9BF62 && apt-get update
apt-get install -y dpkg-dev build-essential zlib1g-dev libpcre3 libpcre3-dev unzip
cd ~
mkdir -p ~/new/nginx_source/
cd ~/new/nginx_source/
apt-get source nginx
rm -rf /var/lib/apt/lists/
apt-get update
apt-get build-dep -y nginx
cd ~
mkdir -p ~/new/ngx_pagespeed/
cd ~/new/ngx_pagespeed/
wget https://github.com/pagespeed/ngx_pagespeed/archive/v${NPS_VERSION}.tar.gz
tar xvfz v${NPS_VERSION}.tar.gz
cd ngx_pagespeed-${NPS_VERSION}/
psol_url=https://dl.google.com/dl/page-speed/psol/${NPS_RELEASE_NUMBER}.tar.gz
psol_url=$(scripts/format_binary_url.sh PSOL_BINARY_URL)
wget ${psol_url}
tar -xzvf $(basename ${psol_url})
cd ~/new/nginx_source/nginx-1.1*.*/debian/
sed -i "s|--prefix=/etc/nginx|--prefix=/etc/nginx --add-module=$HOME/new/ngx_pagespeed/ngx_pagespeed-${NPS_VERSION}|" $HOME/new/nginx_source/nginx-1.1*.*/debian/rules
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment