Skip to content

Instantly share code, notes, and snippets.

@positiveque
Forked from pi0/pagespeed_nginx_ubuntu.sh
Created July 30, 2020 15:41
Show Gist options
  • Select an option

  • Save positiveque/f1a06b433ce3e8fcde6bf74930f53c9e to your computer and use it in GitHub Desktop.

Select an option

Save positiveque/f1a06b433ce3e8fcde6bf74930f53c9e 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!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment