I was looking for a simple way to install mod_pagespeed on a cPanel/WHM server with EasyApache4 (please note that with EasyApache3 you could have just added a custom mode to EasyApache and recompile apache with the new mode). Since EasyApache4 is strictly based on .rpm packages and there is no precompiled .rpm package for mod_pagespeed, you have to create your own .rpm package. After reading and inspecting a few blog posts I decided to write an article in case others might find as usefull this kind of information.
Step 1) Download the pagespeed module from github.com repo
Step 2) Unizp the module
Step 3) Enter the EA4 mod_pagespeed folder
Step 4) Create a file that will take care of the RPM build errors (if you already tried to compile that module according to the instructions from github.com you probably know that RPM build process returns some errors and there is no .rpm package built at the end)
cat > /etc/rpm/macros.apache2 <<EOF
Step 5) Build the .rpm package
rpmbuild --rebuild ea-apache24-mod_pagespeed-latest-stable.src.rpm
Step 6) Install the .rpm package
rpm -ivh /root/rpmbuild/RPMS/x86_64/ea-apache24-mod_pagespeed-latest-stable.x86_64.rpm
Step 7) Restart the apache web service
/etc/init.d/httpd restart (CentOS 6.x)
systemctl restart httpd (CentOS 7.x)
Step 8) Configure mod_pagespeed parameters
In order to do that, you have to edit the configuration file which is located at:
Have fun using Google Pagespeed module for Apache 2.4.x on a cPanel/WHM server with EasyApache4!
Note: I haven’t created this from scratch so I cannot assume the entire credit for this tutorial. Some steps were taken or inspired from other blog posts!