Articles on: WHM

How to install mod_pagespeed in cPanel?

Created by Google, mod_pagespeed is “an open-source Apache module which automatically applies web performance best practices to pages, and associated assets (CSS, JavaScript, images) without requiring that you modify your existing content or workflow.”


This guide assumes you are using cPanel / WHM with EasyApache 4 and have root access to the server.


Create a file called ‘/etc/rpm/macros.apache2’


nano /etc/rpm/macros.apache2


Now, paste the below contents into that file and save it.


%_httpd_mmn 20120211x8664
%_httpd_apxs /usr/bin/apxs
%_httpd_dir /etc/apache2
%_httpd_bindir %{_httpd_dir}/bin
%_httpd_modconfdir %{_httpd_dir}/conf.modules.d
%_httpd_confdir %{_httpd_dir}/conf.d
%_httpd_contentdir /usr/share/apache2
%_httpd_moddir /usr/lib64/apache2/modules


Once the file is saved, login to your WHM and go to EasyApache4, click on ‘Customize’ button present on the selected ‘Currently Installed Packages’.


EA4

%27%20fill-opacity%3D%27.5%27%3E%3Cellipse%20fill%3D%22%239a9a9a%22%20fill-opacity%3D%22.5%22%20rx%3D%221%22%20ry%3D%221%22%20transform%3D%22rotate(-1.9%20981%20-13380.5)%20scale(851.88733%2073.02746)%22%2F%3E%3Cellipse%20fill%3D%22%23fff%22%20fill-opacity%3D%22.5%22%20rx%3D%221%22%20ry%3D%221%22%20transform%3D%22matrix(924.03637%20-80.8427%2021.3453%20243.97786%20513.9%20432.2)%22%2F%3E%3Cellipse%20fill%3D%22%23d5d5d5%22%20fill-opacity%3D%22.5%22%20rx%3D%221%22%20ry%3D%221%22%20transform%3D%22matrix(-4.50202%20-62.8064%20784.29705%20-56.21911%20305.8%20150.2)%22%2F%3E%3Cellipse%20fill%3D%22%23fff%22%20fill-opacity%3D%22.5%22%20rx%3D%221%22%20ry%3D%221%22%20transform%3D%22matrix(24.20094%20242.46212%20-970.88205%2096.90691%20365.8%20446.8)%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E)


There select the second option Apache Modules, you have to install two modules viz mod_http2 and mod_version after that click on next until you reach to the ‘Review’ option and click on ‘Provision’ button. It will install both the selected modules.


mod version

%27%20fill-opacity%3D%27.5%27%3E%3Cellipse%20fill%3D%22%23a2a2a2%22%20fill-opacity%3D%22.5%22%20rx%3D%221%22%20ry%3D%221%22%20transform%3D%22rotate(176.7%20208.7%2015.1)%20scale(976.17188%2073.11187)%22%2F%3E%3Cellipse%20fill%3D%22%23fff%22%20fill-opacity%3D%22.5%22%20rx%3D%221%22%20ry%3D%221%22%20transform%3D%22matrix(-5.2107%20-134.08705%20686.16228%20-26.66462%20634%20307)%22%2F%3E%3Cellipse%20fill%3D%22%23fff%22%20fill-opacity%3D%22.5%22%20rx%3D%221%22%20ry%3D%221%22%20transform%3D%22rotate(-4.3%204449%20-7487.7)%20scale(752.78886%20135.14867)%22%2F%3E%3Cellipse%20fill%3D%22%23bababa%22%20fill-opacity%3D%22.5%22%20rx%3D%221%22%20ry%3D%221%22%20transform%3D%22matrix(4.37213%2032.33698%20-191.04124%2025.82979%2087.6%2091.1)%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E)


mod http2

%27%20fill-opacity%3D%27.5%27%3E%3Cellipse%20fill%3D%22%23a2a2a2%22%20fill-opacity%3D%22.5%22%20rx%3D%221%22%20ry%3D%221%22%20transform%3D%22matrix(-975.51627%2035.77056%20-2.42116%20-66.02872%20322.5%2028)%22%2F%3E%3Cellipse%20fill%3D%22%23fff%22%20fill-opacity%3D%22.5%22%20rx%3D%221%22%20ry%3D%221%22%20transform%3D%22matrix(619.22585%20-22.70598%205.68011%20154.90507%20532.4%20333.4)%22%2F%3E%3Cellipse%20fill%3D%22%23fff%22%20fill-opacity%3D%22.5%22%20rx%3D%221%22%20ry%3D%221%22%20transform%3D%22matrix(-617.28786%2074.70004%20-16.43408%20-135.80391%20406%20332.5)%22%2F%3E%3Cellipse%20fill%3D%22%23bcbcbc%22%20fill-opacity%3D%22.5%22%20rx%3D%221%22%20ry%3D%221%22%20transform%3D%22matrix(252.31591%20-40.43588%2014.39222%2089.80603%20131.5%2025.3)%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E)


After that run the below commands to complete the installation:


wget https://github.com/pagespeed/cpanel/raw/master/EA4/ea-apache24-mod_pagespeed-latest-stable.src.rpm

yum install rpm-build

rpmbuild --rebuild ea-apache24-mod_pagespeed-latest-stable.src.rpm

rpm -Uvh /root/rpmbuild/RPMS/x86_64/ea-apache24-mod_pagespeed*.rpm


This will install the mod_pagespeed module in easyapache4.


Once the mod_pagespeed is installed again login to WHM>>EasyApache4>>Customize>>Apache Modules and search for mod_pagespeed and install it then go to review option and provision it.


Then restart the apache service


/etc/init.d/httpd restart

That is it, mod_pagespeed should now be working on your server. You can check using the following command:
```

curl -I localhost


HTTP/1.1 200 OK

Date: Thu, 28 Jun 2018 13:20:14 GMT

Server: Apache

Upgrade: h2,h2c

Connection: Upgrade

Accept-Ranges: bytes

X-Mod-Pagespeed: 1.13.35.2-0

Vary: Accept-Encoding

Cache-Control: max-age=0, no-cache

Content-Length: 111

Content-Type: text/html

If you have a [managed hosting service](https://host4geeks.com) with us you can request us to install mod_pagespeed on your server.

Updated on: 21/05/2026

Was this article helpful?

Share your feedback

Cancel

Thank you!