Learn Compile and Install Nginx With the PageSpeed Module on Debian 8

September 7, 2019

Table of Contents

In this article, we will see how to compile and install Nginx mainline from the official sources of Nginx with the PageSpeed module, which allows you to accelerate your website through several filters. These filters act on HTML, images, CSS or Javascript.


  • A newly deployed IT Web Services instance running Debian 8.
  • A sudo user.

Manual installation

Update the system.

sudo apt-get update
sudo apt-get dist-upgrade

Install dependencies.

sudo apt install build-essential ca-certificates zlib1g-dev libpcre3 libpcre3-dev tar unzip libssl-dev

Define a variable with the latest version of the PageSpeed module.


Next, we need to download and extract the source code for ngx-pagespeed.

cd /opt
wget https://github.com/pagespeed/ngx_pagespeed/archive/v${NPS_VER}-beta.zip
unzip v${NPS_VER}-beta.zip
rm v${NPS_VER}-beta.zip
cd ngx_pagespeed-${NPS_VER}-beta
[ -e scripts/format_binary_url.sh ] && psol_url=$(scripts/format_binary_url.sh PSOL_BINARY_URL)
wget ${psol_url}
tar -xzvf $(basename ${psol_url})
rm ${NPS_VER}-x64.tar.gz

Compilation and installation of Nginx

Define a variable with the latest version of Nginx.


Or define it via the Nginx website.

NGINX_VER=$(curl -s http://nginx.org/en/CHANGES | awk 'NR==2' | awk '{print $4}')

Next, we need to download the source code for Nginx.

cd /opt
wget -qO- http://nginx.org/download/nginx-${NGINX_VER}.tar.gz | tar zxf -

Configure the parameters and modules. The Nginx PageSpeed module is included.

cd nginx-${NGINX_VER}


make -j $(nproc)


make install

You can verify that the ngx_pagespeed module has been added to Nginx installation as follows.

/usr/local/nginx/sbin/nginx -V

Automatic installation

Get the automation script, which allows you to install several modules, including the PageSpeed module.

wget --no-check-certificate https://raw.githubusercontent.com/Qoraiche/nginx-including-pagespeed/master/nginx-autoinstall.sh -O nginx-autoinstall.sh

Make it executable.

chmod +x nginx-autoinstall.sh

Execute it.


Your Nginx PageSpeed module installation is now complete.

Need help?

Do you need help setting up this on your own service?
Please contact us and we’ll provide you the best possible quote!