Nginx – How to build a Debian package with Google PageSpeed module

nginx photo

Nginx is a high speed web server. Google Pagespeed is an Nginx add on for speeding up web pages at the web server level. This can include minifying javascript, deferring scripts, combining stylesheets and javascript, etc.

Photo by xmodulo

  1. First create and enter a build directory:

    mkdir ~/nginx && cd ~/nginx
  2. Next we get the source for Nginx using APT:

    apt-get source nginx
  3. Now we need to download the Pagespeed module, as well as PSOL, and extract both:

    cd ~
    cd incubator-pagespeed-ngx-
    tar xvf psol/
  4. Now we need to install the build dependencies for Nginx:

    apt-get build-dep nginx
  5. Now we need to edit the configuration for Nginx compilation to add the Pagespeed module:

    nano ~/nginx/nginx-1.16.1/debian/rules

    Add the following to the configure statement (changing /path/to to the real path):

  6. Now using the below command, compile and build the .deb package for Nginx with the Pagespeed module:

    cd ~/nginx/nginx-1.16.1/
    dpkg-buildpackage -b
  7. You should now have a .deb package in ~/nginx. To install this package all you need to do is use dpkg:

    dpkg -i ~/nginx/nginx_1.16.1-1~bionic_amd64.deb

    The package name may be different depending on the target os, in my case bionic, AKA Ubuntu 18.04.

You May Also Like

Leave a Reply

Your email address will not be published. Required fields are marked *