Install mod_pagespeed to Improve Apache Performance on Ubuntu & Debian

mod_pagespeed is an open-source Apache & Nginx Web Server module created by Google to help Make the Web Faster by rewriting web pages to reduce latency and bandwidth. It has several filters that automatically optimize files like HTML, CSS, JavaScript, JPEG, PNG and other resources to speedup your website 30-40% compare with earlier stage. Alternatively you can read mod_pagespeed installation on RPM systems such as CentOS, RHEL & Fedora .It support around 45 famous & most useful PageSpeed filters which will used to optimize your apache performance such a different aspect & parameter. The latest version of Pagespeed 1.9.32.13 released on February 03, 2016 with Security update, Still pagespeed team working hard to improve the performance.

1) Download & Install pagespeed module on Ubuntu, Mint & Debian

Before proceeding mod_pagespeed module, make sure you should install Apache Web Server on your environment. Follow the below steps to install mod_pagespeed module on your apache server.

[Download mod_pagespeed 64-bit package]
$ wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_amd64.deb

[Download mod_pagespeed 32-bit package]
$ wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_i386.deb

[Install at command, if its not installed]
$ sudo apt-get install at

[Install Install mod_pagespeed module]
$ sudo dpkg -i mod-pagespeed-stable_current_amd64.deb

[It will automatically create the mod_pagespeed repo]
# cat /etc/apt/sources.list.d/mod-pagespeed.list
deb http://dl.google.com/linux/mod-pagespeed/deb/ stable main

Note the mod_pagespeed files location for future usage.

[mod_pagespeed Config files]
/etc/apache2/mods-available/pagespeed.conf
/etc/apache2/conf.d/pagespeed_libraries.conf

[only for Debian]
/etc/apache2/mods-available/pagespeed.load

[mod_pagespeed Apache 2.4 file
/usr/lib/apache2/modules/mod_pagespeed_ap24.so

[mod_pagespeed Apache 2.2 file
/usr/lib/apache2/modules/mod_pagespeed.so

[mod_pagespeed cron file
/etc/cron.daily/mod-pagespeed

Change/Modify File permission 755 if no. Otherwise leave as it is.

[Change the file permission for Apache 2.4
$ sudo chmod 755 /usr/lib/apache2/modules/mod_pagespeed_ap24.so

[Change the file permission for Apache 2.2
$ sudo chmod 755 /usr/lib/apache2/modules/mod_pagespeed.so

Restart Apache Web Server to take effect the changes.

[Restart Apache webserver on SysVinit systems]
$ sudo service apache2 restart

[Restart Apache webserver on SysVinit systems]
$ sudo systemctl restart apache2.service

2) Verify pagespeed is running with apache

Just create the phpinfo file and verify it in browser whether pagespeed is running or not. Alternatively we can check in terminal whether mod pagespeed working with apache or not. See below I have running latest stable release of pagespeed (1.9.32.13-0)

$ curl -I localhost
HTTP/1.1 200 OK
Date: Tue, 23 Feb 2016 07:02:12 GMT
Server: Apache/2.4.10 (Debian)
Accept-Ranges: bytes
Vary: Accept-Encoding
X-Mod-Pagespeed: 1.9.32.13-0
Cache-Control: max-age=0, no-cache
Content-Length: 11087
Content-Type: text/html; charset=UTF-8

3) Enable/Disable the module

By default pagespeed module is enabled on Apache after installation. If you want to disable, you can do by editing the pagespeed.conf file.

[Enable pagespeed]
$ sudo nano /etc/apache2/mods-available/pagespeed.conf
ModPagespeed on

[Disable pagespeed]
ModPagespeed off

We can access the Mod_Pagespeed admin page too.
install-mod-pagespeed-on-debian-ubuntu-1
Graphs trend.
install-mod-pagespeed-on-debian-ubuntu-2
Keep smile..because your website is now 30-40% speed compare with earlier…cool)

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...