ngx_pagespeed-install-script
#Install nginx and pagespeed latest version on clean Ubuntu 14.04 x64
Need root right - sudo su
Installation
'wget https://github.com/Levantado/ngx_pagespeed-install-script/releases/download/1a/page-speed.sh ; bash page-speed.sh'
for 15.10 use
'https://github.com/Levantado/ngx_pagespeed-install-script/releases/download/1a/page-speed-1v1.sh ; bash page-speed-1v1.sh'
How to Install nginx and google pagespeed on Ubuntu 14.04 x64
What is it:
Nginx is an HTTP and reverse proxy server, a mail proxy server, and a generic TCP proxy server, originally written by Igor Sysoev. For a long time, it has been running on many heavily loaded Russian sites including Yandex, Mail.Ru, VK, and Rambler. According to Netcraft, nginx served or proxied 22.61% busiest sites in August 2015. Here are some of the success stories: Netflix, Wordpress.com, FastMail.FM.
Ngxpagespeed speeds up your site and reduces page load time by automatically applying web performance best practices to pages and associated assets (CSS, JavaScript, images) without requiring you to modify your existing content or workflow. 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
• and more
Prerequisites
- Ubuntu 14.04 x64 (may 15.05)
- root privileges
- few knowledge using vim
Step 1 Install some Debian package development tools and library
sudo apt-get install dpkg-dev build-essential zlib1g-dev libpcre3 libpcre3-dev unzip
Step 2 Adding nginx repo
sudo nano /etc/apt/sources.list.d/nginx.list
Paste in this two string
deb http://nginx.org/packages/ubuntu/ trusty nginx
deb-src http://nginx.org/packages/ubuntu/ trusty nginx
You may use vim that more helping because that have syntax highlighting. (In vim enable inserting mode press “i”, disabling all mode press “ESC”, exit without save “ZQ”, exit with save ”ZZ”);
This difference
sudo apt-get update
Command stop and show strings like that:
GPG error: http://nginx.org trusty Release: The following signatures couldn't be verified because the public key is not available: NOPUBKEY ABF5BD8xxxxxxx
Don’t worry add this key

sudo sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ABF5BD8xxxxxxx
repeat
sudo apt-get update
Step 3 Downloading and extracting
Step 3.1 Download nginx
Enter root mode
sudo su
Prepare place
cd ~
mkdir -p ~/new/nginx_source/
cd ~/new/nginx_source/
Downloading
apt-get source nginx
apt-get build-dep nginx
Step 3.2 Download pagespeed
Prepare place
cd ~
mkdir -p ~/new/ngx_pagespeed/
cd ~/new/ngx_pagespeed/
You may see this steps in official site https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source
Downloading and unpacking
Check ngx-version on the official site and change if you need.
https://developers.google.com/speed/pagespeed/module/releasenotes
ngx_version=1.10.33.6
wget https://github.com/pagespeed/ngx_pagespeed/archive/release-${ngx_version}-beta.zip
unzip release-${ngx_version}-beta.zip
cd ngx_pagespeed-release-${ngx_version}-beta/
wget https://dl.google.com/dl/page-speed/psol/${ngx_version}.tar.gz
tar -xzf ${ngx_version}.tar.gz
Step 4 Configure before build
cd ~/new/nginx_source/nginx-1.8.1/debian/
Time use vim. That help avoid syntax errors
vim rules
Need add in configure module that strings
--add-module=../../ngxpagespeed/ngxpagespeed-release-1.10.33.6-beta \
after string --prefix=/etc/nginx \
in two section
first section: ovveride_dh_auto_build:
second: configure_debug:
If you see that highlights this string in vim different then other strings check “ \” and “—“ and set manually.
Step 5 Building
cd ~/new/nginx_source/nginx-1.8.1/
dpkg-buildpackage -b
cd ~/new/ngix_source/
dpkg -i nginx_1.8.1-1~trusty_amd64.deb
Step 5.1 Problem with compile CC
mount | grep tmp
export PATH="/usr/bin:$PATH"
Step 6 Check
nginx -V
in text we must see
Now go to you public IP
You must see:
Step 7 Config
Make cache folder
mkdir -p /var/ngx_pagespeed_cache
chown -R www-data:www-data /var/ngx_pagespeed_cache
Enable pagespeed and cache
vim /etc/nginx/nginx.conf
In http section add this strings
pagespeed on;
pagespeed FileCachePath /var/ngx_pagespeed_cache;
Like that
Restart
service nginx restart
Check
curl -I -p http://localhost | grep X-Page-Speed
You must see
It’s all guys!
P.S. for configure like wanna you - go here :
https://developers.google.com/speed/pagespeed/module/configuration
References
https://www.digitalocean.com/community/tutorials/how-to-add-ngx_pagespeed-to-nginx-on-ubuntu-14-04
https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source