NGINX with PageSpeed rules

I was pretty happy with how the Google PageSpeed module allowed me to simplify my build process and automate some performance optimizations I hadn't yet implemented. I was able to stop using grunt tasks for js and css concatenation and minification, have image assets automatically compressed and even get all the CSS required for initial page rendering delivered inline instead of as an external render blocking asset.

You will still need to build NGINX from source in order to enable the PageSpeed module.

Following the build from source instructions verbatim installs nginx at /usr/local/nginx if you modify the ./configure step to install it at the standard location using --sbin-path=/usr/local/sbin then you can start it with nginx directly

./configure --sbin-path=/usr/local/sbin

Test run nginx in order to verify conf file is working

nginx -t

If it is not looking in the desired conf file location you can tell it where to find the new conf files:

/usr/local/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

Make sure your custom install of nginx is going to continue running and restart with the system using upstart


Which is a perfect example except change the binary location from /usr/sbin/nginx to: /usr/local/nginx/sbin/nginx

Also once PageSpeed is in your production environment you will want to add a cache clear step which removes all files in the nginx_cache directory so that any deployment which updates a lot of static files will update immediately instead of after 5 minutes.