Install pagespeed module ( mod_pagespeed ) on Apache Web Server : CentOS / RHEL

The opensource pagespeed module ( mod_pagespeed ) is widely used for speed up the websites. Pagespeed module is available for Apache and Nginx . Currently, to list your website on google top search page , your site must be opened quickly. Hence, speed matters for user end experience also. Now a days, users do not want to visit the website which opens very late.

In this tutorial, we are doing this practical on Apache web server.

Note: The tutorial is applicable to Apache version 2.2 and 2.4 both

Install pagespeed module ( mod_pagespeed ) on Apache Web Server

Follow the given below steps to install mod_pagespeed on Apache web server. At the time of writing this post, the pagespeed module is applicable to Apache version 2.2 and 2.4 .

Download Pagespeed Module

We will use wget command to download the latest Pagespeed module.
You can skip the below given command if you have wget command available on system

yum install wget

As per your Operating system architecture.Download the below given rpm package.

For 64 bit Operating System architecture(x86_64), Download

wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_x86_64.rpm

For 32 bit Operating System architecture(i386), Download

wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_i386.rpm

Install rpm package

Install the downloaded mod-pagespeed rpm package . (Actually it is yum repo package)

rpm -ivh mod-pagespeed-*.rpm 

After this installation, new yum repo file will be created in /etc/yum.repos.d

Check the repo file content by using cat command

cat /etc/yum.repos.d/mod-pagespeed.repo

The below given is reference from our server.Do not copy paste.

[root@webserver ~]# cat /etc/yum.repos.d/mod-pagespeed.repo 
[mod-pagespeed]
name=mod-pagespeed
baseurl=http://dl.google.com/linux/mod-pagespeed/rpm/stable/x86_64
enabled=1
gpgcheck=1
[root@webserver ~]#

Install pagespeed module with yum command

Now use yum command to install pagespeed module.

yum install mod-pagespeed

Check the at command also in your system. If it is not available then use yum command to install at

yum install at

Now, page speed module is installed. And you can check

Two conf file is also created inside /etc/httpd/conf.d
1. /etc/httpd/conf.d/pagespeed.conf (Main configuration file)
2. /etc/httpd/conf.d/pagespeed_libraries.conf

Two pagespeed modules liberary are installed
1./etc/httpd/modules/mod_pagespeed_ap24.so
2. /etc/httpd/modules/mod_pagespeed.so

One file created in /etc/cron.daily/
1. /etc/cron.daily/mod-pagespeed

Restart Apache Service

After installing the pagespeed module restart the Apache service

service httpd restart

Enable/Disable the module

By default, after installation pagespeed module is enabled. The value of ModPagespeed in file /etc/httpd/conf.d/pagespeed.conf decide status of Pagespeed Module

To enable the pagespeed module

vi /etc/httpd/conf.d/pagespeed.conf
ModPagespeed on

To disable the pagespeed module

vi /etc/httpd/conf.d/pagespeed.conf
ModPagespeed off

Note: After editing, do not forget to restart the apache service to make module status effective (service httpd restart)

Verify PageSpeed is running

1. The best way to verify the Pagespeed is running by checking the HTTP response error
Replace example.com with your website address

curl -I http://example.com

Find X-Mod-Pagespeed in HTTP Header, it confirms pagespeed is running

We have installed mod_pagespeed on our server. See the below given reference

pagespeed module

8 thoughts on “Install pagespeed module ( mod_pagespeed ) on Apache Web Server : CentOS / RHEL”

  1. What can I do with this error:

    root@vps [~]# yum install at
    Loaded plugins: fastestmirror, presto, tsflags, universal-hooks
    Setting up Install Process
    Loading mirror speeds from cached hostfile
    * EA4: 208.100.0.204
    * base: mirror.steadfast.net
    * extras: bay.uchicago.edu
    * updates: mirror.solarvps.com
    Package at-3.1.10-48.el6.x86_64 already installed and latest version
    Nothing to do
    root@vps [~]# wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_x86_64.rpm
    –2016-10-20 21:11:39– https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_x86_64.rpm
    Resolving dl-ssl.google.com… 173.194.198.136, 173.194.198.190, 173.194.198.93, …
    Connecting to dl-ssl.google.com|173.194.198.136|:443… connected.
    HTTP request sent, awaiting response… 200 OK
    Length: 6635260 (6.3M) [application/x-redhat-package-manager]
    Saving to: “mod-pagespeed-stable_current_x86_64.rpm”
    100%[====================================================================================================================================================================================================================================>] 6,635,260 3.11M/s in 2.0s
    2016-10-20 21:11:41 (3.11 MB/s) – “mod-pagespeed-stable_current_x86_64.rpm” saved [6635260/6635260]
    root@vps [~]# rpm -ivh mod-pagespeed-*.rpm
    warning: mod-pagespeed-beta_current_x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 7fac5991: NOKEY
    error: Failed dependencies:
    httpd >= 2.2 is needed by mod-pagespeed-beta-1.11.33.4-0.x86_64
    mod-pagespeed-stable conflicts with mod-pagespeed-beta-1.11.33.4-0.x86_64
    httpd >= 2.2 is needed by mod-pagespeed-stable-1.11.33.4-0.x86_64
    mod-pagespeed-beta conflicts with mod-pagespeed-stable-1.11.33.4-0.x86_64

    Reply
  2. Dear Sharad

    Dear Team

    I tried to follow instructions mentioned in your blog to install mod_pagespeed.

    After appying all the filters, I still can not see that .jpg are not converted into wbnp . Moreover, CSS and JS are still same and they are not optimized.

    I am using AWS – EC 2 t2.medium instance [Server: Apache/2.2.15 (CentOS)].

    Here is url where i tried to follow your instructions.

    https://www.example.com/sample.html

    [root@ip- conf.d]# curl -I https://www.example.com
    HTTP/1.1 200 OK
    Date: Tue, 12 May 2015 01:56:51 GMT
    Server: Apache/2.2.15 (CentOS)
    Vary: Accept-Encoding
    Cache-Control: max-age=0, no-cache
    Connection: close
    Content-Type: text/html; charset=UTF-8

    Would you help me to understand how can i enable mod_pagespeed or why filters are not working.

    Thanks

    Reply
    • Check header module in your Apache config file, response header is hidden .Hence, not showing with “curl -I”
      Pagespeed is there in your website, I checked with firebug.
      Pagespeed

      Note: I have renamed the URL which you have given because of security reason.

      Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.