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.
- Small resource inlining.
- HTML rewriting.
- Cache lifetime extension.
see more https://developers.google.com/speed/pagespeed/module/.
- Ubuntu Server 15.04 – 64 bit
- root privileges
What we will do in this tutorial :
- Install the prerequisite packages.
- Installing nginx with ngx_pagespeed.
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
add the line:
deb http://nginx.org/packages/ubuntu/ trusty nginx deb-src http://nginx.org/packages/ubuntu/ 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 keyserver.ubuntu.com --recv-keys KEYNUMBER
sudo apt-get update
Step 2 – Download nginx 1.8 from ubuntu repository
mkdir -p ~/new/nginx_source/
apt-get source nginx
apt-get build-dep nginx
Step 3 – Download Pagespeed
mkdir -p ~/new/ngx_pagespeed/
tar -xzf 18.104.22.168.tar.gz
Step 4 – Configure nginx to build with Pagespeed
add the module under CFLAGS `.configure` :
Step 5 – Build nginx package and Install
The dpkg-buildpackage command will build the nginx.deb under ~/new/ngix_source/ Once package building is complete, please look in the directory:
And then install nginx.
dpkg -i nginx_1.8.0-1~trusty_amd64.deb
Run nginx -V to see the ngx_pagespeed was builted with nginx.
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.