First, I would like to thank Mysterydata for their article on this subject. The thing is they did provide a downloadable library ngx_pagespeed.so but this file is compiled for the Nginx 1.18.0 version. And now VestaCP provide another Nginx version and their library is not compatible anymore.

Some of my websites really need Pagespeed, so I found the way to compile it myself. I will also provide the downloadable library here for the last version.

Downloadable ngx_pagespeed (easy method)

Google Pagespeed version Nginx version ngx_pagespeed
1.13.35.1-0 Nginx 1.19.0 ngx_pagespeed-1.19.0
1.13.35.2-0 Nginx 1.20.1 ngx_pagespeed-1.20.1
1.13.35.2-0 Nginx 1.20.2 ngx_pagespeed-1.20.2

Get the module

Load ngx_pagespeed in Nginx

In /etc/nginx/nginx.conf, add on the first line

Enable ngx_pagespeed on domain vhost

Vhost config files are located on a specific folder with VestaCP :

For each domain, modify both the non-ssl and the ssl config files

Add under server { block add the foloowing  code

Restart Nginx

Check the configs

If the output show OK, proceed with restart

Testing Pagespeed

Test nginx pagespeed is working or not via this Online checker : https://ismodpagespeedworking.com/

Or via cURL

You will see a line like this: X-Page-Speed: 1.13.35.2-0

Compile ngx_pagespeed for any Nginx version

Simply follow the guide from Google itself, at the chapter Build instructions: https://www.modpagespeed.com/doc/build_ngx_pagespeed_from_source

And add the result of

to the line

Example

On my Nginx with VestCP installation, I use the command sudo nginx -V and I have the output

So I will us the ./configure command below

Problems with the building

./configure: error: SSL modules require the OpenSSL library.

You will need to install libssl-dev:

free(): double free detected in tcache 2

If you have this error, you will first need to clean your repository:

And then, use –add-dynamic-module= instead of –add-module= on the ./configure step:

What about the performances?

When I use gtmetrix.com, I could pass from a score of C to a score of B.

 

Catégories : LinuxPrestashop

2 commentaires

[Update 2021] Guide Ultime d'Installation d'une Boutique b2c/b2b Prestashop 1.7 - Partie 1 - Metrodyn · 23 février 2021 à 14 h 34 min

[…] Voir l’article à propos de l’installation de Pagespeed […]

[Update 2021] Guide Ultime d’Installation d’une Boutique Prestashop 1.7 – VPS, myVesta – Partie 1 - Metrodyn · 20 décembre 2021 à 9 h 14 min

[…] Voir l’article à propos de l’installation de PageSpeed […]

Laisser un commentaire

Avatar placeholder

Votre adresse e-mail ne sera pas publiée.