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/

Share this

2
Leave a Reply

avatar
1 Comment threads
1 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
2 Comment authors
MuhammadStephane Recent comment authors

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

  Subscribe  
newest oldest most voted
Notify of
Stephane
Guest

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 »