Skip to content

Instantly share code, notes, and snippets.

@jniltinho
Last active February 23, 2024 13:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jniltinho/26c775c401f67db73e17dc9641c251ec to your computer and use it in GitHub Desktop.
Save jniltinho/26c775c401f67db73e17dc9641c251ec to your computer and use it in GitHub Desktop.
Install Pagespeed Nginx
#!/bin/bash
## Install PageSpeed Ubuntu 20.04
## Run as root (sudo su)
## https://www.howtoforge.com/how-to-install-nginx-with-google-pagespeed-on-ubuntu-20-04/
## https://www.linuxbabe.com/nginx/compile-the-latest-nginx-with-ngx_pagespeed-module-on-ubuntu
## https://www.techrepublic.com/article/how-to-install-the-latest-version-of-nginx-on-ubuntu-server-18-04/
## https://www.tecmint.com/install-ngx_pagespeed-to-optimize-nginx-performance-on-ubuntu/
## nginx -v
## Ubuntu 10.04
NGINX_VERSION=1.18.0
apt-get update
apt-get install -y build-essential zlib1g-dev libpcre3 libpcre3-dev unzip uuid-dev nginx dpkg-dev git
mkdir -p /usr/local/src/nginx
cd /usr/local/src/nginx
wget http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz
tar -zxvf nginx-$NGINX_VERSION.tar.gz
cd /usr/local/src
git clone https://github.com/apache/incubator-pagespeed-ngx.git
cd incubator-pagespeed-ngx/
git checkout latest-stable
wget https://dl.google.com/dl/page-speed/psol/1.13.35.2-x64.tar.gz ; tar -xvzf 1.13.35.2-x64.tar.gz
cd /usr/local/src/nginx/nginx-$NGINX_VERSION
./configure --with-compat --add-dynamic-module=/usr/local/src/incubator-pagespeed-ngx
make modules
cp objs/ngx_pagespeed.so /usr/share/nginx/modules/
echo 'load_module modules/ngx_pagespeed.so;' >/usr/share/nginx/modules-available/mod-pagespeed.conf
ln -s /usr/share/nginx/modules-available/mod-pagespeed.conf /etc/nginx/modules-enabled/50-mod-pagespeed.conf
nginx -t
systemctl reload nginx
## Ubuntu 18.04
NGINX_VERSION=1.21.6
echo 'deb [arch=amd64] http://nginx.org/packages/mainline/ubuntu/ bionic nginx
deb-src http://nginx.org/packages/mainline/ubuntu/ bionic nginx' >/etc/apt/sources.list.d/nginx.list
curl -L http://nginx.org/keys/nginx_signing.key|apt-key add -
apt-get update
apt-get install -y nginx=1.21.6-1~bionic
apt-get install -y build-essential zlib1g-dev libpcre3 libpcre3-dev unzip uuid-dev dpkg-dev git
mkdir -p /usr/local/src/nginx
cd /usr/local/src/nginx
wget http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz
tar -zxvf nginx-$NGINX_VERSION.tar.gz
cd /usr/local/src
git clone https://github.com/apache/incubator-pagespeed-ngx.git
cd incubator-pagespeed-ngx/
git checkout latest-stable
wget https://dl.google.com/dl/page-speed/psol/1.13.35.2-x64.tar.gz ; tar -xvzf 1.13.35.2-x64.tar.gz
cd /usr/local/src/nginx/nginx-$NGINX_VERSION
./configure --with-compat --add-dynamic-module=/usr/local/src/incubator-pagespeed-ngx
make modules
cp objs/ngx_pagespeed.so /etc/nginx/modules/
## Add in /etc/nginx/nginx.conf
## load_module modules/ngx_pagespeed.so;
nginx -t
systemctl reload nginx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment