• Skip to main content
  • Skip to primary sidebar
  • Home
  • WordPress
  • web Hosting
  • linux
  • mysql
  • nginx
  • apache2
  • devops

Raju Ginni

wordpress tutorials seo hosting etc

You are here: Home / nginx server tutorials (installation, configuration, performance tuning, security) / Pagespeed module install, configure, monitor, errors ft nginx &apache

Pagespeed module install, configure, monitor, errors ft nginx &apache

Table of Contents

Toggle
  • Installing Pagespeed module on nginx as dynamic module
    • To know version of os & nginx
    • to know linux distribution version
    • Remove / rename old compiled module
    • Install devtools
  • compiling Pagespeed module with latest nginx
    • check version
    • create directory
    • download latest nginx
  • Download  Pagespeed Module
    • Set environment variable
    • download module
    • //make sure to rename if already loaded module
  • Copying module & loading module in nginx.conf
  • Pagespeed module nginx configuration
    • create a directory
    • add configuration
    • WordPress caching plugin vs Google pagespeed module vs fastCGI cache
    • monitoring
    • troubleshoot
    • Pagespeed module filters

Installing Pagespeed module on nginx as dynamic module

first you need to compile the module on same os like ubuntu 18.04 & same nginx version nginx 13

To know version of os & nginx

You can run this commands
nginx -v
//It shows current version of nginx

to know linux distribution version

lsab- v
//
installing
risky: you can also compile & install it on a live server.
just like upgrading nginx in live server. Just we need restart / reload.
if any errors we can solve it by nginx error log.

Remove / rename old compiled module

from
mv objs/ngx_pagespeed.so  objs/ngx_pagespeed13.9so
mv /etc/nginx/modules/ngx_pagespeed.so /etc/nginx/modules/ngx_pagespeed13.9.so

Install devtools

sudo apt-get install unzip gcc make libpcre3-dev zlib1g-dev
strongly recommend that you compile dynamic modules on a separate system, which we refer to here as the “build environment
same os and same nginx.

compiling Pagespeed module with latest nginx

check version

nginx -v
nginx version: nginx/1.15.2
Download the same version of nginx to compile already covered above.

create directory

mkdir -p /etc/new/nginx/
cd /etc/new/nginx/

download latest nginx

wget -qO – http://nginx.org/download/nginx-1.15.2.tar.gz | tar zxfv –
or
wget http://nginx.org/download/nginx-1.15.2.tar.gz
tar -xzvf nginx-1.15.2.tar.gz

Download  Pagespeed Module

check latest release stable here.
check latest version and find the version number set it as variable.

Set environment variable

Include only the numeric part of the version string, not the ‑stable or ‑beta suffix.
assigning value to airbale
$ NPS_VERSION=numeric-part-of-version-string

download module

NPS_VERSION=1.13.35.2-stable
wget https://github.com/apache/incubator-pagespeed-ngx/archive/v${NPS_VERSION}.zip
unzip v${NPS_VERSION}.zip
nps_dir=$(find . -name “*pagespeed-ngx-${NPS_VERSION}” -type d)
cd “$nps_dir”
NPS_RELEASE_NUMBER=${NPS_VERSION/beta/}
NPS_RELEASE_NUMBER=${NPS_VERSION/stable/}
psol_url=https://dl.google.com/dl/page-speed/psol/${NPS_RELEASE_NUMBER}.tar.gz
[ -e scripts/format_binary_url.sh ] && psol_url=$(scripts/format_binary_url.sh PSOL_BINARY_URL)
wget ${psol_url}
tar -xzvf $(basename ${psol_url})
// HInt: if failed check https://dl.google.com/dl/page-speed/psol/1.13.35.1-stable.tar.gz

You will be here

/incubator-pagespeed-ngx-1.13.35.1-stable
or
$ cd ../nginx-1.15.2

//make sure to rename if already loaded module

ls /etc/nginx/modules/
mv /etc/nginx/modules/ngx_pagespeed.so /etc/nginx/modules/ngx_pagespeed13.9.so
$ ./configure –add-dynamic-module=../ngx_pagespeed-${NPS_VERSION} –with-compat
adding module in ../ngx_pagespeed-1.13.35.2-stable
./configure: error: no ../ngx_pagespeed-1.13.35.2-stable/config was found
incubator-pagespeed-ngx-1.13.35.2-stable
incubator-pagespeed-ngx-1.13.35.2-stable
./configure –add-dynamic-module=../incubator-pagespeed-ngx-${NPS_VERSION} –with-compat
$ make modules
  1. $ cd ../nginx-1.15.2
  2. $ ./configure –with-compat –add-dynamic-module=/tmp/incubator-pagespeed-ngx-1.13.35.2
  1. $ make modules
//incubator-pagespeed-ngx-1.13.35.2

Copying module & loading module in nginx.conf

  1. sudo cp objs/ngx_pagespeed.so /etc/nginx/modules/
ls /etc/nginx/modules/
/usr/lib/nginx/modules
nano /etc/nginx/nginx.conf
nginx.con top pf http
load_module modules/ngx_pagespeed.so;
nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
sudo nginx -s reload
nginx -V
at server block
Troubleshooting
PageSpeed Serf fetch failure rate extremely high; only 14 of 31 recent fetches fully successful; is fetching working?
pagespeed: rollback gzip, explicit configuration in /etc/nginx/nginx.conf:99
nginx.conf:99 gzip on;
mod_pagespeed automatically enables mod_deflate for compression.
https://blog.stackpath.com/nginx-performance-tips-google-pagespeed

Pagespeed module nginx configuration

create a directory

mkdir /var/ngx_pagespeed_cache && chown www-data:www-data /var/ngx_pagespeed_cache

add configuration

nano /etc/nginx/conf.d/pagespeed.conf
pagespeed on;
pagespeed FileCachePath /var/ngx_pagespeed_cache;
pagespeed FileCacheSizeKb 102400;
pagespeed FileCacheCleanIntervalMs 3600000;
pagespeed FileCacheInodeLimit 500000;
pagespeed RewriteLevel CoreFilters; #PassThrough
pagespeed EnableFilters combine_css,collapse_whitespace,remove_comments,prioritize_critical_css;
pagespeed EnableFilters combine_javascript;
pagespeed EnableFilters rewrite_images;
pagespeed ModifyCachingHeaders off;
location ~ “\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+” {
add_header “” “”;
}
location ~ “^/pagespeed_static/” { }
location ~ “^/ngx_pagespeed_beacon$” { }
https://github.com/apache/incubator-pagespeed-ngx/issues/1129
nginx -t && nginx -s reload
http://blog.teamtreehouse.com/automating-web-performance-best-practices-mod_pagespeed
http://xmodulo.com/speed-nginx-web-server-pagespeed.html
Configuring
You must understand the variables and the value there is pretty guidelines available at pagespeed module websites.
Gzip
css rewrite
js
compression level
minify or combine
Put critical css on head & remaining on footer or body
to you can view the live data in browser,
Monitoring
Error handling
lot of headaches, it adds a query string to and end page page url.
Make sure to block to avoid duplicate & thin content issues from Google,

WordPress caching plugin vs Google pagespeed module vs fastCGI cache

wordpress caching plugins utilizes php backend code, MySQL+p so there is a latency.
Pagespeed module directly handles &serves with help of nginx.
limitation of pagespeed module
only optimize/ rebuild the web pages according to Google pagespeed rules.
it rebuild s & stores as cache and serves cached pages.
Cached expiration time also important.
we have lot to understand & configure in order to work with pagespeed module.
Tried for few months, upon migrating to new server not installed 3rd time.
Reason: profit/ time.
my website not drawing any users, so thought limited resources fine for limited visitors.

monitoring

http()
#pagespeedmodule
pagespeed Statistics on;
pagespeed StatisticsLogging on;
pagespeed LogDir /var/log/pagespeed;
pagespeed StatisticsLoggingIntervalMs 60000;
pagespeed StatisticsLoggingMaxFileSizeKb 1024;
pagespeed StatisticsPath /ngx_pagespeed_statistics;
pagespeed GlobalStatisticsPath /ngx_pagespeed_global_statistics;
pagespeed MessagesPath /ngx_pagespeed_message;
pagespeed ConsolePath /pagespeed_console;
pagespeed AdminPath /pagespeed_admin;
pagespeed GlobalAdminPath /pagespeed_global_admin;
pagespeed UsePerVhostStatistics on;
##
Writing to mod_pagespeed_message failed. Verify that MessageBufferSize is not set to 0 in pagespeed.conf.
By default, the size of this buffer is zero, and no messages will be retained.
Apache:
ModPagespeedMessageBufferSize 100000
Nginx:
pagespeed MessageBufferSize 100000;
flush
touch /var/ngx_pagespeed_cache/cache.flush
Also read  enable brotil on nginx

troubleshoot

curl -H “PageSpeedFilters: +debug” https://rajuginni.com
?PageSpeedFilters=+debug

Pagespeed module filters

# HTTPS Support# pagespeed FetchHttps enable;
# PageSpeed Filters# CSS Minification# pagespeed EnableFilters combine_css,rewrite_css;
# JS Minification# pagespeed EnableFilters combine_javascript,rewrite_javascript;
# Images Optimization#pagespeed EnableFilters lazyload_images;#pagespeed EnableFilters rewrite_images;#pagespeed EnableFilters convert_jpeg_to_progressive,convert_png_to_jpeg,convert_jpeg_to_webp,convert_to_webp_lossless;
# Remove comments from HTML #pagespeed EnableFilters remove_comments; # Remove WHITESPACE from HTML #pagespeed EnableFilters collapse_whitespace;
# CDN Support#pagespeed MapRewriteDomain cdn.example.com www.example.com;
View Pagespeed statistics
You can view Pagespeed statics by poinitng your browser to http://example.com/ngx_pagespeed_statistics
Disable Pagespeed temporary
You can disable pagespeed temporary by using this url: http://example.com/?PageSpeed=off
pagespeed EnableFilters responsive_images,resize_images;
ou can build ngx_pagespeed by using –add-dynamic-module= instead of using –add-module=.
So you would use something like:
./configure –add-dynamic-module=/path/to/ngx_pagespeed
After running make and make install the dynamic ngx_pagespeed.so module should be located in the modules directory which resides in parallel to sbin where the nginx binary lives.
Subsequently you should be able to load ngx_pagespeed as a dynamic module by adding the following (early on) to the main context in nginx.conf:
load_module “modules/ngx_pagespeed.so”;
Just like pagespeed module letsencrypt SSL migration not possible. You may look at this.
Letsencrypt SSL Installation on apache/Nginx ubuntu / debian
Note: article updates frequently (don’t get disappointed)

Primary Sidebar

nginx server tutorials (installation, configuration, performance tuning, security)

  • Letsencrypt SSL Installation on apache/Nginx ubuntu / debian wordpress
  • fix error 520 522 524 on cloudflare wordpress godaddy nginx etc
  • nginx fastcgi cache wordpress how to configure
  • install LEMP Stack on 22.04 LTS Nginx MySQL PHP fpm #wordpress #digital ocean
  • Apache vs nginx (connection handling, modules, memory usage)
  • Pagespeed module install, configure, monitor, errors ft nginx &apache
  • nginx errors (504,502, 413, unable to start, syntax errors)
  • nginx conf explained best config file performance tuning tips nginx.conf location errors tutorial
  • use nginx as reverse proxy and load balancer for apache wordpress
  • nginx rewrite rules with examples 301 redirection
  • nginx modules list (enable, disable, upgrade, install dynamic module)
  • php fpm pool manager configuration settings based on server spike high cpu wordpress
  • php fpm restart nginx ubuntu enable status page, monitor etc
  • what is TTFB & how to Reduce it (server response time) Google pagespeed
  • letsencrypt install configure on ubuntu / debian nginx
  • Top 10 tips to improve nginx server security
  • nginx performance tuning connections, buffers file descriptors
  • enable brotli compression nginx brotli vs gzip
  • nginx installation on ubuntu 20.04 LTS
  • monitor nginx request with nginx status amplify datadog new relic
  • SSL faster reduce TLS hand shake improve https performance
  • nginx rate limiting explained by location time specific url
  • datadog nginx integration installation process
  • newrelic nginx integration process and errors fix and metrics
  • php fpm seems busy fixed warning and max children reached to handle max connections / requests
  • Php fpm configuration for 1000 concurrent connections server busy max children reached
  • php fpm ondemand vs dynamic vs Static (the dynamic pool problem)
  • nginx upstream response is buffered to a temporary file
  • php fpm install ubuntu 20.04 nginx
  • install phpmyadmin ubuntu nginx 22.04
  • upgrade php fpm ubuntu nginx 7.4 to 8.2
  • nginx add last modified header (remove, php wordpress)
  • php fpm dynamic pool manager settings
  • nginx fastcgi cache purge
  • nginx open file limit connections ulimits sysctl
  • php fpm high cpu usage WordPress 4 solutions nay work for you
  • nginx buffer size for wordpress
  • Cloudflare error code 524 nginx a timeout error occured
  • server configuration for 1000 concurrent users

hi i am raju ginni, primalry i manage wordpress websites on GCP cloud platform as a cloud engineer, and create content on passionate things.
you can follow me on youtbe

© 2025 - All Rights Reserved Disclaimer & Privacy Policy