Skip to content

Instantly share code, notes, and snippets.

@pi0
Last active July 6, 2023 21:58
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save pi0/a4ce5fdfe5a2a8fa7b51315d1f13bb00 to your computer and use it in GitHub Desktop.
Save pi0/a4ce5fdfe5a2a8fa7b51315d1f13bb00 to your computer and use it in GitHub Desktop.
Install PageSpeed on Ubuntu Nginx Extras
# Deps
sed -i "s|# deb-src|deb-src|" /etc/apt/sources.list
apt update
export DEPS=" \
build-essential zlib1g-dev libpcre3-dev unzip uuid-dev \
debhelper po-debconf libexpat-dev libgd-dev libgeoip-dev libhiredis-dev \
libluajit-5.1-dev libmhash-dev libpam0g-dev libperl-dev libssl-dev libxslt1-dev quilt"
apt install -y $DEPS
# NXG Pagespeed
ln -s /bin/bash /bin/sudo
bash <(curl -f -L -sS https://ngxpagespeed.com/install) -y
# Nginx
mkdir ~/nginx
cd ~/nginx
apt source nginx-extras
cd nginx-*
# Build
sed -i 's|extras_configure_flags := |extras_configure_flags := --add-module=${HOME}/incubator-pagespeed-ngx-latest-stable |' debian/rules
dpkg-buildpackage -b
# Install
cd ..
dpkg -i nginx-extras_*.deb
# Cleanup
apt remove -y $DEPS
apt autoremove -y
cd ~
rm incubator-* nginx -rf
# Verify installation
[ ! -z "`nginx -V 2>&1 | grep pagespeed`" ] && echo "Nginx with Pagespeed successfully installed!"
@pi0
Copy link
Author

pi0 commented Sep 20, 2018

Easy usage:

curl -#L -sS https://gist.githubusercontent.com/pi0/a4ce5fdfe5a2a8fa7b51315d1f13bb00/raw/pagespeed_nginx_ubuntu.sh | bash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment