Nginx VestaCP PageSpeed how to on CentOS 6.X

How to install mod_pagespeed for your Nginx with vestaCP panel in few steps.. so let’s go for it..

First you have to know whic version of Nginx you have installed on server..

nginx -v or to nginx -V for more info.

But first let’s install some needed stuff

yum install gcc-c++ pcre-devel zlib-devel make unzip openssl-devel

And then go for page speed module..

cd ngx_pagespeed-release-
tar -xzvf

So when you finish this check your nginx version with config strings with nginx -V and you can just copy those strings and add –add-module=$HOME/ngx_pagespeed-release-

something like this.. but don’t just copy this code couse you might have different strings then these I have posted..

./configure –prefix=/etc/nginx –sbin-path=/usr/sbin/nginx –conf-path=/etc/nginx/nginx.conf –error-log-path=/var/log/nginx/error.log –http-log-path=/var/log/nginx/access.log –pid-path=/var/run/ –lock-path=/var/run/nginx.lock –http-client-body-temp-path=/var/cache/nginx/client_temp –http-proxy-temp-path=/var/cache/nginx/proxy_temp –http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp –http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp –http-scgi-temp-path=/var/cache/nginx/scgi_temp –user=nginx –group=nginx –with-http_ssl_module –with-http_realip_module –with-http_addition_module –with-http_sub_module –with-http_dav_module –with-http_flv_module –with-http_mp4_module –with-http_gunzip_module –with-http_gzip_static_module –with-http_random_index_module –with-http_secure_link_module –with-http_stub_status_module –with-http_auth_request_module –with-mail –with-mail_ssl_module –with-file-aio –with-ipv6 –with-http_spdy_module –with-cc-opt=’-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector –param=ssp-buffer-size=4 -m64 -mtune=generic’ –add-module=$HOME/ngx_pagespeed-release-

Then you just need this..

make install

Restart your nginx to check if it starts fine just to be sure that nginx.conf and stirngs are ok.

So the next step is to add some code to vestacp template files…
start editing the VESTA templates located in



You have to add code before
include %home%/%user%/conf/web/nginx.%domain%.conf*;

And the code is:

pagespeed On;
pagespeed RewriteLevel CoreFilters;

# HTTPS Support
pagespeed FetchHttps enable,allow_self_signed;

pagespeed EnableFilters lazyload_images,collapse_whitespace,insert_dns_prefetch,dedup_inlined_images,defer_javascript,pedantic,trim_urls,sprite_images,extend_cache_pdfs,remove_comments,resize_mobile_images,inline_preview_images,insert_image_dimensions,convert_to_webp_lossless,local_storage_cache,inline_google_font_css,prioritize_critical_css,rewrite_style_attributes,move_css_to_head,move_css_above_scripts,outline_javascript,outline_css,combine_heads;

pagespeed FileCachePath /var/ngx_pagespeed_cache;

location ~ “\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+” { add_header “” “”; }
location ~ “^/pagespeed_static/” { }
location ~ “^/ngx_pagespeed_beacon$” { }

And thats it.. now you just have to rebuild web to set new tempaltes to your web domains:

Login to Vesta
Use the checkbox next to the users
Select “rebuild web” from drop-down

And if you need to set some pages not to be cached or folder, urls, you can to it like this:

in your /home/user/conf/web/nginx.conf
add lines like this but change so it will suit your needs:

pagespeed Disallow “*/jquery-ui-1.8.2.custom.min.js”;
pagespeed Disallow “*/admin/*”;

Or you can cache only selected folders/files:

pagespeed Disallow “*”;
pagespeed Allow “http://**.html”;
pagespeed Allow “http://**/images/*.png”;
pagespeed Allow “http://**/styles/*.css”;
pagespeed Disallow “*/images/captcha/*”;

And finaly if you need test page you can check here…