How to Install and Configure mod_pagespeed with Apache

install and configure mod_pagespeed

How to Install and Configure mod_pagespeed with Apache

mod_pagespeed is an Apache module that improves website speed and performance. It offers more than 40 website optimizations such as image, css, js, html optimization, deferred loading as well as caching. Here’s how to install and configure mod_pagespeed with Apache.

 

How to Install and Configure mod_pagespeed with Apache

Here are the steps to install and configure mod_pagespeed with Apache.

 

1. Install mod_pagespeed with Apache

Open terminal and run the following command

On RHEL/CentOS and Fedora

----------- On 32-bit Systems -----------------
# wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_i386.rpm
# yum install at   [# if you don't already have 'at' installed]
# rpm -Uvh mod-pagespeed-stable_current_i386.rpm

----------- On 64-bit Systems -----------------
# wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_x86_64.rpm
# yum install at   [# if you don't already have 'at' installed]
# rpm -Uvh mod-pagespeed-stable_current_x86_64.rpm

On Debian and Ubuntu

----------- On 32-bit Systems -----------------
$ wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_i386.deb
$ sudo dpkg -i mod-pagespeed-stable_current_i386.deb
$ sudo apt-get -f install

----------- On 64-bit Systems -----------------
$ wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_amd64.deb
$ sudo dpkg -i mod-pagespeed-stable_current_amd64.deb
$ sudo apt-get -f install

Bonus Read : How to Check if mod_expires is enabled

 

2. Configure mod_pagespeed in Apache

After installation, mod_pagespeed is automatically enabled in Apache. You can configure mod_pagespeed by modifying its main configuration file located at:

  • /etc/httpd/conf.d/pagespeed.conf  (for RPM/CentOS/Fedora based distributions)
  • /etc/apache2/mods-enabled/pagespeed.conf (for Debian/Ubuntu based distributions)

If you want to turn off mod_pagespeed, add the following line to your pagespeed.conf file

ModPagespeed off

If you want to turn it on, add

ModPagespeed on

You will find more configuration options at https://www.modpagespeed.com/

Bonus Read : How to Enable mod_headers in Apache

 

3. Restart Apache Server

Restart Apache web server to Apply changes.

Ubuntu/Debian

$ sudo service apache2 restart

CentOS/Redhat/Fedora

$ sudo service httpd restart

Bonus Read : How to Secure Apache with Let’s Encrypt

 

4. Verify mod_pagespeed module

Open terminal and run the following command to send request to your IP or domain.

# curl -D- http://your_IP_or_domain/ | less

You should see the X-mod-Pagespeed header in your output

HTTP/1.1 200 OK
Date: Fri, 04 Mar 2016 07:37:57 GMT
Server: Apache/2.4.6 (CentOS) PHP/5.4.16
...
X-Mod-Pagespeed: 1.9.32.13-0
---

 

Ubiq makes it easy to visualize data in minutes, and monitor in real-time dashboards. Try it Today!

Post a Comment

0 Comments