Tips / Nginx

How to install Nginx PageSpeed module

Time ago we announced the availability of PageSpeed for Nginx. Now a few months later we decided to write a How to install Nginx PageSpeed tutorial. The next tutorial will show you how to install Pagespeed on Nginx in a few easy steps.

For the installation, we will need to compile nginx from souce with the PageSpeed module, as Nginx doesn’t support Dynamic module loading (DSO), unless you want to build your own rpm or deb files (which will not be covered in this tutorial).

PageSpeed requirements for rpm based (CentOS, RHEL, Fedora)

yum install gcc-c++ pcre-dev pcre-devel zlib-devel make

PageSpeed requirements for Debian/Ubuntu

sudo apt-get install build-essential zlib1g-dev libpcre3 libpcre3-dev

Download and unpack the latest version of the PageSpeed module from here:


Download and unpack latest nginx version from here

tar -xvzf nginx-1.4.2.tar.gz

Compile nginx with pagespeed module

cd nginx-1.4.2/
./configure --add-module=$HOME/ngx_pagespeed-release-
make install

Activate pagespeed module inside nginx configuration

Add this lines into /etc/nginx/nginx.conf or /usr/local/nginx/nginx.conf file:

pagespeed on;
pagespeed FileCachePath /var/ngx_pagespeed_cache;

Once this is done, just restart nginx to apply the changes:

service nginx restart

Testing the pagespeed module:

curl -I '' | grep "Speed" -i

You should see this in the headers:


Another way to check if it’s working is taking a look at the source code of your website, you should see something like this:


Important: check your logs and monitor websites for a few weeks, as this module is experimental and in my case it caused random error 500 pages on a few WordPress blogs.

Fore more information, please refer to Ngx_Pagespeed Official Website

Popular search terms:

  • https://www scalescale com/tips/nginx/how-to-install-nginx-pagespeed-module/
  • installing google page speed modules nginx
  • pagespeed nginx compilation

Esteban Borges

Linux Geek, Webperf Addict, Nginx Fan. CTO @Infranetworking

  • laur

    It is ok for static websites or blogs when is needed just reading in 90% of cases, but if you have an forum pagespeed will slow down your forum by 30%. Will work for forums but you need to make more advanced settings …