How to Install Mod_Pagespeed on Centos+cPanel ?


>> What is mod_pagespeed ?

mod_pagespeed is basically an open-source module for Apache which does the task of optimizing the web-pages and its resources. Its an automated process and makes use of the filters for enhancment of web performance by re-writing the resources. Performance enhancement for
Apache HTTP Server can easily be achieved using the module.
Installation ::

1. Login to your server using root login

2. Before you start the installation, make sure “mod_deflate” is enabled via easy apache.

3. Determine the version of your kernel via the command ::

# uname -a

In my case its a 64 bit version

root@server [~]# uname -ar
Linux server.server.com 2.6.18-028stab099.3 #1 SMP Wed Mar 7 15:20:22 MSK 2012 x86_64 x86_64 x86_64 GNU/Linux
4. Once you deteemind the vesion, Go to the directory ::

root@server [~]# cd /usr/local/src

6. Create a directory mod_pagespeed

root@server [~]# mkdir mod_pagespeed
v# cd mod_pagespeed

7. Now download the source of mod_pagespeed using the link ::

>> Link :: http://code.google.com/speed/page-speed/download.html
>> Go to the link :: https://developers.google.com/speed/docs/mod_pagespeed/download
>> Right click on the “mod_pagespeed 64-bit .rpm (CentOS) and copy the link location

NOTE :: Location is :: https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-beta_current_x86_64.rpm

8 . Download >>

# root@server [~]# wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-beta_current_x86_64.rpm

9. Install the downloaded RPM ::

# root@server [~]# rpm2cpio mod-pagespeed-beta_current_x86_64.rpm | cpio -idmv

The outpu should be as below ::
root@server [~]rpm2cpio mod-pagespeed-beta_current_x86_64.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

10. Copy the mod_pagespeed.so to the apache modules ::

root@server [~]# cp /usr/local/src/mod_pagespeed/usr/lib64/httpd/modules/mod_pagespeed.so /usr/local/apache/modules/

And then copy the mod_pagespeed.conf to the apache conf directory ::

root@server [~]# cp /usr/local/src/mod_pagespeed/etc/httpd/conf.d/pagespeed.conf /usr/local/apache/conf/

11. Give permissions ::

root@server [~]# chmod 755 /usr/local/apache/modules/mod_pagespeed.so

12. Create cache files for the mod_pagespeed ::

root@server [~]# mkdir /var/mod_pagespeed/{cache,files} -p

13. Change ownership of cache files ::

root@server [~]# chown nobody:nobody /var/mod_pagespeed/*

>> Mod_pagespeed needs mod_deflate to be loaded in Apache. If it is not loaded tyou 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.

14. 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,

root@server [~]# vi /usr/local/apache/conf/pagespeed.conf
=================
<IfVersion < 2.4>
LoadModule pagespeed_module /usr/local/apache/modules/mod_pagespeed.so
</IfVersion>
=================

=================
<IfModule !mod_deflate.c>
LoadModule deflate_module /usr/local/apache/modules/mod_deflate.so
</IfModule>
=================

15. After that, we’ll 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 ::

root@server [~]#/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 ::

root@server [~]# 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/*.

One Response to “How to Install Mod_Pagespeed on Centos+cPanel ?”

  1. I actually had some difficulties with mod_pagespeed on my system using the depot-tools (gclient) so I had to do everything manually in a somewhat complicated manner and ran into some irritating issues but your directions were the only ones that was helpful in this manner.
    My mod_page speed works — touch on wood — perfectly as of now.
    Thank you for supplying good directions.

    Faithfully,
    -k0nsl

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: