Install mod-pagespeed on WHM/Cpanel Server
How to install mod pagespeed on WHM/Cpanel server
Mod_pagespeed is an opensource module created by Google to speed up the loading of web pages by applying several necessary optimizations. It rewrites webpages to reduce latency and bandwidth.
This module is available for both Apache and Nginx servers. However, the process of installation and packages differ for the two web servers. When you install the pagespeed module in apache, it is automatically enabled. In the case of NGINX, however, you will need to make changes to the NGINX configuration file located at NGINX.conf. In case of NGINX, you will need to build the module from sources, while packages are available for Apache servers, if you would like to use the terminal to install pagespeed. You can install either stable or beta from the downloads page. These packages are available for Centos, Fedora, Debian and Ubuntu platforms.
Here, we are discussing the Apache pagespeed module and its benefits as well as how to install it on a WHM/cpanel server. Once you install mod_pagespeed on an Apache server, it automatically applies the performance best practices to your web pages and related assets like css, js, and images, without the need to modify your content or workflow.
The pagespeed module is built on pagespeed optimization libraries and deployed across a very large number of websites. Most popular hosting and CDN providers offer mod_pagespeed. However, that is not all about mod_pagespeed. You can further optimize it to suit your website’s needs as there are more than 40 optimization filters available including :
- Image optimization, compression, and resizing
- Cache extension, domain sharding, and domain rewriting
- and many others...
Install mod_pagespeed on a WHM/Cpanel server via EasyApache4
You can install mod_pagespeed on a WHM/Cpanel server without even running any code. The EasyApache 4 interface makes it easier for the WHM users to install all the necessary modules by just toggling a few buttons.
Login to WHM as a root user and search for Easy in the search box. You will see EasyApache 4 listed in the software section. Click on EasyApache4 to open the interface.
Inside the interface, you will see the available packages listed. The currently installed package (the one you need to customize) is listed at the top.
EasyApache 4 interface makes it easier to install modules and also provides updates for the various modules, MPMs or PHP extensions whenever there are updates available. You can update all of them by just a single click.
To install mod_pagespeed click on customize on the currently installed package.
It will open a new interface for customization. You will see various options listed on the left including Apache MPM, Apache modules, PHP versions, PHP extensions and additional packages.
Now, you need to click on Apache modules. A small search box will appear on the right above the listed modules. Type pages in it and the mod_pagespeed will come up. Toggle the button next to mod_pagespeed to install it. Check the image below:
Now, click on review on the left and then review the changes. Installing mod_pagespeed will also install a few other necessary modules if they are not installed already.
Click on provision at the bottom and wait till the provision process lasts. Provisioning does not take more than a few minutes, after which mod_pagespeed will be installed and active on your server.
To find out if the module has been installed, you can go to the terminal and run the following command:
It will bring up a list of the available modules and you will see pagespeed_module (shared) included in the list.
$ Loaded Modules: core_module (static) so_module (static) watchdog_module (static) http_module (static) log_config_module (static) logio_module (static) version_module (static) unixd_module (static) access_compat_module (shared) alias_module (shared) auth_basic_module (shared) authn_core_module (shared) authn_file_module (shared) authz_core_module (shared) authz_host_module (shared) authz_user_module (shared) autoindex_module (shared) brotli_module (shared) deflate_module (shared) dir_module (shared) env_module (shared) filter_module (shared) mime_module (shared) mpm_event_module (shared) negotiation_module (shared) pagespeed_module (shared) reqtimeout_module (shared) rewrite_module (shared) setenvif_module (shared) socache_shmcb_module (shared) ssl_module (shared)
Now, you have successfully installed and enabled mod-pagespeed on your WHM/Cpanel server.
You also have the option to make changes to the module’s configurations to suit your website’s needs. As I have already mention, there are more than 40 optimization filters available.
The configurations related to mod_pagespeed are available in the pagespeed.conf file.
Centos/Fedora: sudo nano /etc/httpd/conf.d/pagespeed.confDebian/Ubuntu: sudo nano /etc/apache2/mods-available/pagespeed.conf
If you do not find the file at the regular location, you can try this:
sudo nano /etc/apache2/conf.modules.d/510_pagespeed.conf
Otherwise just run the following command to find its location:
find / -name *pagespeed*.conf
The contents of the pagespeed configuration file (pagespeed.conf) look like this: --
Most of the configurations are well explained in the file and you can easily understand them and make changes per your needs. On an Apache server, here are some common directives that can be changed inside the pagespeed.conf file while using the module:
to turn the module on: ModPagespeed On
to turn the module off: ModPagespeed off
to keep the module on standby: ModPagespeed standby
Totally unplug or fully switch off the module: ModPagespeed unplugged
When you enable mod_pagespeed, it also automatically enables the mod_deflate if it is not enabled already for compression. Follow this link to learn more about mod_pagespeed configurations.
Note: If you are using WP Rocket on your website, you may receive a warning after enabling the pagespeed module. It is because WP Rocket applies nearly all the optimizations provided by the pagespeed module. That’s why, it advises you to disable the module so that you can avoid any conflicts. So, if you are using WP Rocket on your blog, you will not need the pagespeed module and you can keep it off.