This tutorial exists for these OS versions

On this page

Google has just released PageSpeed Beta for nginx, the nginx equivalent of mod_pagespeed for Apache. This module applies web performance best practices to pages, and associated assets (CSS, JavaScript, images) and therefore speeds up your web site and reduces load times. This tutorial explains how to use PageSpeed with nginx on Debian Wheezy.

I do not issue any guarantee that this will work for you!

1 Building nginx With PageSpeed

nginx does not support dynamic loading of modules, therefore we must rebuild it with PageSpeed support. We will build nginx as a .deb package so that we can replace our existing nginx installation with it (or easily install it on other systems).

Create the build directory first:

cd /usr/src
mkdir pagespeed && cd pagespeed

Make sure you have deb and deb-src lines for Wheezy in /etc/apt/sources.list:

Our nginx version is 1.2.1. Let's go to the debian/modules directory of the downloaded nginx sources...

cd /usr/src/pagespeed/nginx-1.2.1/debian/modules

... and download the PageSpeed sources:

git clone https://github.com/pagespeed/ngx_pagespeed.git

Let's edit the debian/rules file:

vi /usr/src/pagespeed/nginx-1.2.1/debian/rules

In that file you will find four config.status sections (config.status.full, config.status.light, config.status.extras, config.status.naxsi). Add the line --add-module=$(MODULESDIR)/ngx_pagespeed \ to each of them, right before the $(CONFIGURE_OPTS) >$@ line, e.g. as follows:

Create the cache directory and restart nginx (please note that whenever you modify the PageSpeed configuration, no matter if in the main nginx configuration or in a vhost, you must restart nginx - a simple reload does not work):

About The Author

Falko Timme is the owner of Timme Hosting (ultra-fast nginx web hosting). He is the lead maintainer of HowtoForge (since 2005) and one of the core developers of ISPConfig (since 2000). He has also contributed to the O'Reilly book "Linux System Administration".

4 Comment(s)

Comments

Actually, I had to deviate a little to get this working. Specifically, I had to download both the mod_PageSpeed sources as well as PSOL sources, and grabbed release packages so they matched. Following the instructions at https://github.com/pagespeed/ngx_pagespeed/archive/v1.7.30.1-beta.tar.gz