mod_pagespeed
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
1 | wget https://github.com/pagespeed/cpanel/archive/master.zip |
Step 2) Unizp the module
1 | unzip master.zip |
Step 3) Enter the EA4 mod_pagespeed folder
1 | cd cpanel-master/EA4 |
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)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | cat > /etc/rpm/macros.apache2 <<EOF %_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 EOF |
Step 5) Build the .rpm package
1 | rpmbuild --rebuild ea-apache24-mod_pagespeed-latest-stable.src.rpm |
Step 6) Install the .rpm package
1 | rpm -ivh /root/rpmbuild/RPMS/x86_64/ea-apache24-mod_pagespeed-latest-stable.x86_64.rpm |
Step 7) Restart the apache web service
1 2 | /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:
1 | /etc/apache2/conf.modules.d/456_pagespeed.conf |
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!
Hello Bogdan Stoica,
I get this error message at step 7) :
“error: Failed dependencies:
ea-apache24-mod_version is needed by ea-apache24-mod_pagespeed-latest-stable.x86_64”
What can I do?
Regards
Yo could issue a yum -y install ea-apache24-mod_version and see if it installs that .rpm package or not.
Didn’t experience that problem to be honest with you. What OS do you have? CentOS 6 or 7?
I cant find this file:
/etc/apache2/conf.modules.d/456_pagespeed.conf
Please check if there is any file in /etc/apache2/conf.modules.d/ with pagespeed.conf. The starting id might be different in your case.