Installing mod_pagespeed into cpanel/whm in centos

Here is another exciting thing that google has release and i really wish to document this down so that i could reuse it on all of my servers since i can see a good amount of optimization done on the server by mod_pagespeed. Anyway without anymore bull crap, i shall starts.

Firstly, you might want to visit mod_pagespeed download page and standby for the time being. And my machine is a 64bit machine so if you are running on 32bit just remove all the '64' you see in the instruction. eg. "lib64"

Firstly login into your server as "root" and start firing the below commands,

cd /usr/local/src
mkdir mod_pagespeed
cd mod_pagespeed
rpm2cpio mod-pagespeed-stable_current_x86_64.rpm | cpio -idmv
cp /usr/local/src/mod_pagespeed/usr/lib64/httpd/modules/ /usr/local/apache/modules/
cp /usr/local/src/mod_pagespeed/etc/httpd/conf.d/pagespeed.conf /usr/local/apache/conf/
chmod 755 /usr/local/apache/modules/
mkdir /var/mod_pagespeed/{cache,files} -p
chown nobody:nobody /var/mod_pagespeed/*

mod_pagespeed has a dependency that you'll want to enable: mod_deflate (the httpd source directory (httpd-2.2.21) may vary depending on your install):

/usr/local/apache/bin/apxs -c -i /home/cpeasyapache/src/httpd-2.2.21/modules/filters/mod_deflate.c

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, the LoadModule directives should fetch the modules in "modules/":

LoadModule pagespeed_module /usr/local/apache/modules/
LoadModule deflate_module /usr/local/apache/modules/
ModPagespeedFileCachePath            "/var/mod_pagespeed/cache/"
ModPagespeedGeneratedFilePrefix      "/var/mod_pagespeed/files/"

And then open /usr/local/apache/conf/includes/pre_main_global.conf and add:

Include "/usr/local/apache/conf/pagespeed.conf"

Next restart apache

/etc/init.d/httpd restart

And we are done!

1&1 Hosting $.99* .COM Domain! Get going with GoDaddy!