There is a new version of this tutorial available for Ubuntu 20.04 (Focal Fossa).

How to Install nginx and google pagespeed on Ubuntu 15.04 (Vivid Vervet)

Nginx (engine-x) is a open source and high performance HTTP server, reverse proxy and IMAP/POP3 proxy server. The outstanding features of Nginx are: stability, rich feature set, simple configuration and low resource consumption. Nginx is being used by some of the largest websites on the internet and is gaining more and more popularity in the webmaster community. This tutorials shows how to build a nginx .deb package for Ubuntu 15.04 from source that has Google pagespeed module compiled in.

Pagespeed is a web server module developed by Google to speed up a website response times, optimize html and reduce the page load time. ngx_pagespeed features include :

  • Image optimization: stripping meta-data, dynamic resizing, recompression.
  • CSS & JavaScript minification, concatenation, inlining, and outlining.
  • Small resource inlining.
  • Deferring image and JavaScript loading.
  • HTML rewriting.
  • Cache lifetime extension.

see more


  • Ubuntu Server 15.04 - 64 bit
  • root privileges

What we will do in this tutorial :

  1. Install the prerequisite packages.
  2. Installing nginx with ngx_pagespeed.
  3. Testing.

Install the prerequisite packages

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

Installing nginx with ngx_pagespeed

Step 1 - Adding nginx repository

vim /etc/apt/sources.list.d/nginx.list

add the line:

deb trusty nginx
deb-src trusty nginx

Update your repository:

sudo apt-get update

note : if you get the messege : GPG error [...] NO_PUBKEY [...] bla bla

please add the the key:

sudo sudo apt-key adv --keyserver --recv-keys KEYNUMBER
sudo apt-get update

Step 2 - Download nginx 1.8 from ubuntu repository

sudo su
cd ~
mkdir -p ~/new/nginx_source/
cd ~/new/nginx_source/
apt-get source nginx
apt-get build-dep nginx

Step 3 - Download Pagespeed

cd ~
mkdir -p ~/new/ngx_pagespeed/
cd ~/new/ngx_pagespeed/
unzip release-${ngx_version}

cd ngx_pagespeed-release-
tar -xzf

Step 4 - Configure nginx to build with Pagespeed

cd ~/new/nginx_source/nginx-1.8.0/debin/
vim rules

add the module under CFLAGS `.configure` :

--add-module=../../ngx_pagespeed/ngx_pagespeed-release- \

adding pagespeed to nginx

adding pagespeed to nginx

Step 5 - Build nginx package and Install

cd ~/new/nginx_source/nginx-1.8.0/
dpkg-buildpackage -b

The dpkg-buildpackage command will build the nginx.deb under ~/new/ngix_source/ Once package building is complete, please look in the directory:

cd ~/new/ngix_source/

nginx builded with pagespeed

And then install nginx.

dpkg -i nginx_1.8.0-1~trusty_amd64.deb

Install nginx


Run nginx -V to see the ngx_pagespeed was builted with nginx.

nginx -V

nginx -V


The nginx web server there is a stable and fast open source http server that supports a variety of modules for optimization. One of these modules is the 'PageSpeed module' which is developed by google. Unlike apache, nginx modules are not dynamically loadable, so you have to select the desired modules before you build the nginx package.

Share this page:

Suggested articles

7 Comment(s)

Add comment


By: Matthew Lenz

It's being discontinued in a few months.

By: till

Hi Matthew, you seem to mix up the googe pagespeed service with the google pagespeed module for nginx. the google pagespeed services gets discontinued in favor of the pagespeed module. the above tutorial is about compiling nginx with the pagespeed module, it is not about the pagespeed service.

By: zokii1983

        --add-module=../../ngx_pagespeed/ngx_pagespeed-release- \./configure: error: invalid option "    "debian/rules:19: recipe for target 'override_dh_auto_build' failedmake[1]: *** [override_dh_auto_build] Error 1make[1]: Leaving directory '/root/new/nginx_source/nginx-1.8.0'debian/rules:11: recipe for target 'build' failedmake: *** [build] Error 2dpkg-buildpackage: error: debian/rules build gave error exit status 2

By: Natan Felles

It's works with ISPConfig 3?

I search for the /etc/nginx/sites-* folders and do not see.

By: till

No, this guide is not compatible with ISPConfig.

By: george

After following the following tutorial

I tried this one, to update nginx to the latest version compiled with ngx_pagespeed.

Unfortunately, I had issues with my ISPCONFIG installation.

Can you please provide some help for those who already have nginx & ispconfig installed?

Best regards.

By: Natan Felles

Hello, george!

I tried this tutorial, with caution to the packages versions and are working well: