1. Login to your server using root login
2. Determine the version of your kernel via the command:
# uname -ar
3. Once you determind the version, Go to the directory:
# cd /usr/local/src
4. Create a directory mod_pagespeed
# mkdir mod_pagespeed
# cd mod_pagespeed
5. Now download the source of mod_pagespeed using the link:
Go to the link :
https://developers.google.com/speed/docs/mod_pagespeed/downloadRight click on the “mod_pagespeed 64-bit .rpm (CentOS) and copy the link location
6. Download the RPM to server:
# wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_x86_64.rpm
7. Install the downloaded RPM:
# rpm2cpio mod-pagespeed-stable_current_x86_64.rpm | cpio -idmv
The output should be as below:
./etc/cron.daily/mod-pagespeed - Can't use this under this install
./etc/httpd/conf.d/pagespeed.conf
./etc/httpd/conf.d/pagespeed_libraries.conf
./usr/bin/pagespeed_js_minify - Can use this as standalone. Refer Google documents
./usr/lib64/httpd/modules/mod_pagespeed.so
./usr/lib64/httpd/modules/mod_pagespeed_ap24.so
./var/mod_pagespeed/cache
8. Let's start copying the files into their correct spots: *One line each*
# cp /usr/local/src/mod_pagespeed/usr/lib64/httpd/modules/mod_pagespeed.so /usr/local/apache/modules/
# cp /usr/local/src/mod_pagespeed/usr/lib64/httpd/modules/mod_pagespeed_ap24.so /usr/local/apache/modules/
# cp /usr/local/src/mod_pagespeed/etc/httpd/conf.d/pagespeed.conf /usr/local/apache/conf/
# cp /usr/local/src/mod_pagespeed/etc/httpd/conf.d/pagespeed_libraries.conf /usr/local/apache/conf/
9. Give permissions:
# chmod 755 /usr/local/apache/modules/mod_pagespeed.so
# chmod 755 /usr/local/apache/modules/mod_pagespeed_ap24.so
10. Create cache files for the mod_pagespeed:
# mkdir /var/mod_pagespeed/{cache,files} -p
11. Change ownership of cache files:
# chown nobody:nobody /var/mod_pagespeed/*
Mod_pagespeed needs mod_deflate to be loaded in Apache. If it is not loaded you can include it using the command below:
# /usr/local/apache/bin/apxs -c -i /home/cpeasyapache/src/httpd-2.2.22/modules/filters/mod_deflate.c
NOTE : the apache version “httpd-2.2.16” could be change according to your server. In my case its httpd-2.2.22.
12. After that, we’ll have to edit the mod_pagespeed configuration file located at /usr/local/apache/conf/pagespeed.conf to reflect the correct paths,
# vi /usr/local/apache/conf/pagespeed.conf
=================
<IfVersion < 2.4>
LoadModule pagespeed_module /usr/local/apache/modules/mod_pagespeed.so
</IfVersion>
<IfVersion >= 2.4.2>
LoadModule pagespeed_module /usr/local/apache/modules/mod_pagespeed_ap24.so
</IfVersion>
# Only attempt to load mod_deflate if it hasn't been loaded already.
<IfModule !mod_deflate.c>
LoadModule deflate_module /usr/local/apache/modules/mod_deflate.so
</IfModule>
=================
13. After that, we need to include the mod_pagespeed configuration in Apache’s configuration file (/usr/local/apache/conf/httpd.conf):
=================
Include “conf/pagespeed.conf”
=================
In order to keep the changes permanant run the command below:
#/usr/local/cpanel/bin/apache_conf_distiller –update
This will then ensure that your changes are integrated into the templates which WHM cPanel uses to regenerate the httpd.conf file after an automatic update.
You’re done now restart the apache:
# service httpd restart
If everything is fine, apache will start normally and as your domains begin to get hits, you will see data being written in to /var/mod_pagespeed/*.