Last active
July 6, 2023 21:58
-
-
Save pi0/a4ce5fdfe5a2a8fa7b51315d1f13bb00 to your computer and use it in GitHub Desktop.
Install PageSpeed on Ubuntu Nginx Extras
This file contains hidden or 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
# 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
Easy usage:
curl -#L -sS https://gist.githubusercontent.com/pi0/a4ce5fdfe5a2a8fa7b51315d1f13bb00/raw/pagespeed_nginx_ubuntu.sh | bash