Nginx + Google Pagespeed Debian Package

The normal Debian mirrors do not carry the nginx package with the Google Pagespeed Module. These instructions will allow you to create your own package that includes Pagespeed. The nginx package is from wheezy-backports which has a newer copy of nginx than the normal wheezy repo, remove -backports from any commands you run if you do not want that version.

You will need to install the following packages for the build process (you don’t need to build them on your web server, I use a server just for builds):

Install the dependencies needed for the build:

Create a new directory and download a copy of the source:

To make things easier, set $nginx to the version of nginx:

Google Pagespeed

Go to the Google Pagespeed build page. Copy the text from the text box with the heading “Then download ngx_pagespeed” without the “cd ~”.

Go into the nginx modules directory and paste the commands from the Google site:

Take note of the folder the ngx_pagespeed release zip file is extracted to (eg. ngx_pagespeed-release-1.7.30.4-beta). Edit the /usr/src/nginx/${nginx}/debian/rules file so that the pagespeed module is compiled in. In the file search for light_configure_flags, full_configure_flags and extras_configure_flags. Each block will have one or more “–add-module” parts, add another pointing to the pagespeed folder:

Make sure the directory name is correct.

Building Package

Make sure you are in the directory where the source code was extracted and then run dch -i to increment the version and add an entry into the change log.

The packages can then be built with dpkg-buildpackage -b:

The /usr/src/nginx will have the .deb files that can be installed on the web servers as normal or uploaded to your own apt repoistory.

Configuration

Edit /etc/nginx/nginx.conf and add the following:

Edit any of sites (usually in /etc/nginx/sites-available/) and add the following:

Restart nginx and pagespeed will then be enabled.

Filters can be enabled specifically with pagespeed EnableFilters. This can be defined in the main configuration file or the site configuration, eg. in /etc/nginx/sites-available/test.com

For more complete config options see the docs.

Posted in Linux, Web and tagged , , , .

Leave a Reply

Your email address will not be published.