Install mod_pagespeed module in cPanel
The mod_pagespeed is one of one of the more recently popular modules for Apache. The mod_pagespeed is an open-source module that optimizes Web pages and their resources for better performance. It is an output filter for Apache and that can be configured through configuration files or a .htaccess file. This post helps you to install mod_pagespeed on cPanel server.
The main use of this module is to improve the website performance. This can be achieved by acting as an output filter for Apache. An “output filter” is a something that transforms the data before it’s sent to the client.
How to install mod_pagespeed module with EasyApache 3
The installation is very simple. A custom mod_pagespeed module is available for CPanel. It allows installation of mod_pagespeed via easyapache.
Installation Steps:
1. Clone the installation scripts onto the CPanel server.
/usr/local/cpanel/3rdparty/bin/git clone https://github.com/pagespeed/cpanel.git /tmp/pagespeed/
2. Create Speed.pm.tar.gz
cd /tmp/pagespeed/Easy tar -zcvf Speed.pm.tar.gz pagespeed mkdir -p /var/cpanel/easy/apache/custom_opt_mods/Cpanel/Easy mv Speed.pm Speed.pm.tar.gz -t /var/cpanel/easy/apache/custom_opt_mods/Cpanel/Easy/ cd && rm -rf /tmp/pagespeed
3. Login into the cPanel WHM > EasyApache and look for “mod_pagespeed” option. Alternatively, you can run the easyapache installer from command line (/scripts/easyapache).
/scripts/easyapache
Install mod_pagespeed with EasyApache 4
Create the file /etc/rpm/macros.apache2 using your favourite editor. I have using vim here.
vim /etc/rpm/macros.apache2
Add the following lines of code in 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
Then, run the following commands:
yum install rpm-build cpio ea-apache24-mod_version cd /usr/local/src/ 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
Restart Apache:
/etc/init.d/httpd restart
Verify the installation using following command:
httpd -M | grep pagespeed
Additional Information:
The below links will help you to Configure mod_pagespeed module.
- mod_pagespeed module configuration: click here
- configuring mod_pagespeed filters: click here
For more information, see Google’s documentation.
If you like the post and wish to receive more articles from us, please like our FB page: Grepitout
Your suggestions and feedbacks will encourage us and help to improve further, please feel free to write your comments.
For more details on our services, please drop us an E-mail at info@grepitout.com
How to get this to work with the new Easyapache4 Update from WHM?
You can try installing mod_pagespeed rpm in order to get it work with EA4.
https://developers.google.com/speed/pagespeed/module/download
As a web host we use Google Pagespeed on our servers and all clients are quite happy with the speed and site optimizations. All sites give more than 80 Pagespeed score. So, you can say its quite effective.