09 May

How to install google pagespeed on easyapache 4 – WHM/Cpanel

What is Google page speed?

Google PageSpeed is a family of tools by Google Inc, designed to help a website’s performance optimizations. Mod_pagespeed  is an open-source  Apache HTTP Server or Nginx web-servers module, which automatically applies chosen filters to pages and associated assets, such as stylesheets (css), JavaScript, and HTML files, as well as to images and website cache requirements.

If you haven’t guessed it, this module directly complements Google’s PageSpeed Insights. It’s a great tool for giving you feedback on what can be done to optimize your site. What I’ve found is many of the issues this tool reports back to you can be resolved automatically by the PageSpeed module , Simply by installing it.

Installation Procedure (CentOS):

  •    yum install rpm-build cpio ea-apache24-mod_version
  •    wget https://github.com/pagespeed/cpanel/raw/master/EA4/ea-apache24-mod_pagespeed-latest-stable.src.rpm
  •     rpmbuild --rebuild ea-apache24-mod_pagespeed-latest-stable.src.rpm
  •    rpm -ivh /root/rpmbuild/RPMS/x86_64/ea-apache24-mod_pagespeed*.rpm
  •    /etc/init.d/httpd restart or service httpd restart

Note: 1- if you face following error on Step 3 :
“RPM build errors:
File must begin with "/": %{_httpd_moddir}/*.so
File must begin with "/": %{_httpd_modconfdir}/*.conf"

Just create a file named “macros.apache2” in ‘/etc/rpm/ directory and paste the below content into that and then restart from step 3.

%_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

2- you may face following error:
“rpmbuild –rebuild ea-apache24-mod_pagespeed-latest-stable.src.rpm
Installing ea-apache24-mod_pagespeed-latest-stable.src.rpm
error: ea-apache24-mod_pagespeed-latest-stable.src.rpm cannot be installed”

Just look at your screen , go 1 step back and check the downloaded file name in some case may be different most of people just run ”  rpmbuild –rebuild ea-apache24-mod_pagespeed-latest-stable.src.rpm” command but sometimes file name may be downloaded in different name on your server for example may be file saved as ea-apache24-mod_pagespeed-latest-stable.src.rpm.9 so in this case you should change file name in command before running that for above example just add .9 in end of command
rpmbuild –rebuild ea-apache24-mod_pagespeed-latest-stable.src.rpm.9

Now Login into your WHM panel > Software > EasyApache4 and look for “mod_pagespeed” option and enable it after that restart apache again and run insight  then check your website speed performance!

Configuring Google mod_pagespeed
The installation script will copy “pagespeed.conf” file into ” /usr/local/apache/conf/ ” on your server. Please consult the following pages to customize your mod_pagespeed configuration:

mod_pagespeed module configuration
configuring mod_pagespeed filters

For example of the different filters in action and detailed documentation for each, please see https://modpagespeed.com/doc/

0 0 votes
Article Rating
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Newest Most Voted
Inline Feedbacks
View all comments
2 years ago

I tried your procedure as well as some other similar ones but, I always end up with the same issue. Once I’m done install mod_pagespeed, when I go to WHM > EA4, the mod_pagespeed module is already enabled but there is no pagespeed.conf file whatsoever on the entire server. I tried to disable mod_pagespeed and then re-enable it but it didn’t work. When I disable it, EA4 uninstalls mod_pagespeed and mod_version. I cannot re-enable them afterward, they’re simply not available anymore. I have to use yum and rpm to reinstall mod_version and mod_pagespeed. And then I’m back at square one.… Read more »

2 years ago
Reply to  Stephane

“pagespeed.conf” may saved with a number at end like pagespeed347.conf, did you check it?