About this article
One of the more recently popular modules for Apache is mod_pagespeed. It is an output filter for Apache 2.2+ that can be configured through a variety of options through configuration files or a .htaccess file. An “output filter” is a something that transforms the data before it’s sent to the client. In other words, it’s a layer between your website and what the user’s browser receives when they visit your URL. Speed Up the Web The goal of mod_pagespeed is to speed up your website. It does this by applying filters to a variety of files in order to reduce the number of trips the browser has to make to grab what it needs, to reduce the size of those files and to optimize the length those files are cached.
Installation is very simple. It’ll vary depending on the operating system you use. Ubuntu and Debian have packages you can download and install (or any Linux distribution that uses .DEB packages). Other Linux distributions can download the source and build from that.
How to Download the Software?
wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_amd64.deb
wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_i386.deb
Code language: JavaScript (javascript)
How to Install mod pagespeed?
sudo dpkg -i mod-pagespeed-*.deb
apt-get -f install
rm mod-pagespeed-*.deb
Code language: Bash (bash)
The module enables itself automatically when installed. However, you must restart Apache for it to start working.
service apache2 restart or /etc/init.d/apache2 restart
Code language: Bash (bash)
You should now have a working version of mod_pagespeed up and running on your VPS. You can check this by looking at your page’s response headers. There should be a value for “X-Mod-Pagespeed” with the version number you installed. Setup The installation package handles a lot of configuration out-of-the-box. In fact, there are conservative defaults that are automatically enabled on Apache. Depending on the Apache version you’re running, you’ll get a different version of the module installed and enabled. If you’re running Apache 2.2, mod_pagespeed.so will be installed; Apache 2.4 users will use mod_pagespeed_ap24.so. Note: mod_pagespeed only works with Apache 2.2 and greater. There is also a bug with Apache 2.4.1 that prevents it from working with that version. Apache 2.4.2 or greater should be used. Additionally, configuration files have been added to your Apache installation. The primary configuration file is pagespeed.conf. This file is located at: /etc/apache2/mods-available/
How to configure mod_pagespeed? You can use whatever text editor you want to edit the configuration file. For this tutorial, we’ll be using nano. To start editing the main configuration file, use the following command:
pico /etc/apache2/mods-available/pagespeed.conf
By default, mod_pagespeed rewrites everything it can. You can disable certain files (for example Javascript libraries) from being rewritten with the following directive:
Restart Apache Don’t forget if you’re using the pagespeed.conf or VirtualHost files to alter the settings, you’ll have to restart Apache for the settings to take effect. You can do this with the following commands: service apache2 restart or /etc/init.d/apache2 restart Check if the mod is loaded with the command apachectl -M
Conclusion
In this article we learned how to install and use Apache mod pagespeed. If you know other good Apache mods, please tell us in the comments bellow.
We hope you enjoyed this article. if that is so please rate this page with the stars bellow and subscribe to our YouTube channel or follow us on twiter.