The PageSpeed module is available for both Apache and Nginx web servers. The common name is PageSpeed module.

It is usually named mod_pagespeed in the context of the Apache web server. And specifically for the Nginx web server, it is usually named as ngx_pagespeed.

This article will help you to how to install mod_pagespeed and ngx_pagespeed on CentOS 8

Install mod_pagespeed Apache

Use the following commands to download latest module packages on your system.

# wget

Install the downloaded packages as well as at package on your system.

# dnf install at

# rpm -U mod-pagespeed-stable_current_x86_64.rpm

Main configuration file stored – /etc/httpd/conf.d/pagespeed.conf

Restart the Apache web server

# systemctl restart httpd

The default mod_pagespeed is ready and now you able to verify module.

# httpd -M | grep pagespeed_module
pagespeed_module (shared)

# curl -I

HTTP/1.1 200 OK
Date: Tue, 11 Feb 2020 11:49:04 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Set-Cookie: __cfduid=df5c731fb37ee255e9a0753a8a0f1f7a21581421744; expires=Thu, 12-Mar-20 11:49:04 GMT; path=/;; HttpOnly; SameSite=Lax
Accept-Ranges: bytes
Cache-Control: max-age=0, no-cache
CF-Cache-Status: DYNAMIC

Install ngx_pagespeed from a package repository

Add ngx_pagespeed to our repository

# dnf install

Install latest stable NGINX

# dnf install nginx

Install the PageSpeed module

# dnf install nginx-module-pagespeed

To enable the module you should add the next to /etc/nginx/nginx.conf file

load_module modules/; 

And add the next to http field of your virtualhost

http {
pagespeed On; pagespeed FileCachePath "/var/cache/ngx_pagespeed/";
pagespeed EnableFilters combine_css,combine_javascript;

Restart nginx web server

# systemctl restart nginx

Verify module installation

# curl -I localhost
HTTP/1.1 200 OK
Server: nginx/1.16.1
Content-Type: text/html
Connection: keep-alive
Vary: Accept-Encoding
Date: Tue, 11 Feb 2020 12:30:47 GMT
Cache-Control: max-age=0, no-cache

You have successfully installed PageSpeed module on your CentOS 8 server.