From mod_pagespeed’s docs, I quote:

mod_pagespeed is an open-source Apache module that automatically optimizes web pages and resources on them. It does this by rewriting the resources using filters that implement web performance best practices. Webmasters and web developers can use mod_pagespeed to improve the performance of their web pages when serving content with the Apache HTTP Server.

mod_pagespeed includes several filter that optimize JavaScript, HTML and CSS stylesheets. It also includes filters for optimizing JPEG and PNG images. The filters are based on a set of best practices known to enhance web page performance. Webmasters who set up mod_pagespeed in addition to configuring proper caching and compression on their Apache distribution should expect to see an improvement in the loading time of the pages on their websites.

Sounds interesting. Mod_pagespeed is brand new, and running it with Apache on a Cpanel server is a very easy task. While you can follow the instructions mentioned here to build from source, you can also use the binary.

But then, it fails to install correctly on a Cpanel server as it requires httpd package. Still, we can extract the files from the binary and copy it over to the necessary paths to get it up and running in a few minutes time 🙂 This is how I did it on a Apache v2.2 + CPanel server running on CentOS 5.5 (32-bit):

[root@server2 ~]# cd /usr/src
[root@server2 src]# wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-beta_current_i386.rpm
[root@server2 src]# mkdir mod-pagespeed
[root@server2 src]# cd mod-pagespeed
[root@server2 mod-pagespeed]# rpm2cpio ../mod-pagespeed-beta_current_i386.rpm | cpio -idmv
./etc/cron.daily/mod-pagespeed
./etc/httpd/conf.d/pagespeed.conf
./usr/lib/httpd/modules/mod_pagespeed.so
./var/mod_pagespeed/cache
./var/mod_pagespeed/files
3135 blocks
[root@server2 mod-pagespeed]# cp ./etc/httpd/conf.d/pagespeed.conf 
/usr/local/apache/conf/
[root@server2 mod-pagespeed]# cp ./usr/lib/httpd/modules/mod_pagespeed.so 
/usr/local/apache/modules/
[root@server2 mod-pagespeed]# chmod 755 /usr/local/apache/modules/mod_pagespeed.so
[root@server2 mod-pagespeed]# mkdir /var/mod_pagespeed/{cache,files} -p
[root@server2 mod-pagespeed]# chown nobody:nobody /var/mod_pagespeed/*

Mod_pagespeed needs mod_deflate to be loaded in Apache. If it is not yet installed, you can just include the same from apache source, like:

[root@server2 mod-pagespeed]# /usr/local/apache/bin/apxs -c -i 
/home/cpeasyapache/src/httpd-2.2.14/modules/filters/mod_deflate.c

Now, edit /usr/local/apache/conf/pagespeed.conf and change the LoadModule lines to point to these paths:

LoadModule pagespeed_module modules/mod_pagespeed.so

# Only attempt to load mod_deflate if it hasn’t been loaded already.

<IfModule !mod_deflate.c>

LoadModule deflate_module modules/mod_deflate.so

And finally, include pagespeed.conf in /usr/local/apache/conf/httpd.conf:

Include “conf/pagespeed.conf”

and then restart apache:

[root@server2 mod-pagespeed]# 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/*. Just a reminder that this module seems to write a lot of data in apache error log. You might need to monitor the server load and i/o stats for some time to ensure that everything is stable.

NOTE: The above guide is strictly for 32-bit servers. If you are running on 64-bit, then you need the 64-bit package (.rpm). Please check the comments section for its url.