Earlier this week, Google released an open source Apache module to simplify the optimization of your content. The module, mod_pagespeed, will do all sorts of magic like minify your JS/CSS and optimize images, and a handful of other optimizations that seem (from limited testing) to improve your servers performance considerably.
Google has provided a couple of RPM’s to help with installation, unfortunately, if you’re running DirectAdmin on CentOS, they won’t work. DirectAdmin runs a compiled Apache with some slightly different defaults and installing using YUM or RPM will fail dependency checks.
In this article, I’ll explain how to get around the dependency issues and adjust your configuration. I have to warn you that this is NOT something I recommend you do on a regular basis unless you’re an experienced Linux Admin, in which case you probably won’t need this tutorial. Overriding RPM dependencies can have some adverse effects on your system. In this case we know most DirectAdmin / CentOS systems share a very similar configuration, so it’s not much of a risk.
Download a copy of the CentOS RPM or wget it from your shell:
wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-beta_current_i386.rpm <– 32bit
wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-beta_current_x86_64.rpm <– 64bit
Since you’re running on a DirectAdmin server, trying to install using YUM or RPM will fail dependency checks since Apache is built from source. We’ll have to force the installation and make a couple of changes to our systems configuration files:
rpm -i –nodeps mod-pagespeed-beta_current_.rpm
And add the following to the top of the file:
#Google PageSpeed Module
Next you’ll need to edit your main httpd.conf file:
Find and remove the line:
If you’d like to change the options for PageSpeed, it’s configuration file is located in /etc/httpd/conf.d/pagespeed.conf
Once everything is set, we’ll need to restart Apache and test to see if the module loaded properly:
service httpd restart
apachectl -t -D DUMP_MODULES | grep pagespeed
If you get the following output, everything should be installed and functioning properly:
You should also check any .htaccess files you may use and remove any instances of ‘setoutputfilter’ as this will probably override what mod_pagespeed is doing.
There you have it! Load up a copy of FireFox with the PageSpeed installed and check out how your score has improved. In my case, with all other caching disabled, I went from a score of 60 to an 82. Not a bad improvement if you ask me!