Install Google Mod_Pagespeed on RHEL, CentOS and Fedora

mod_pagespeed is an open source module for Apache web server that automatically optimize Web Pages to improve better performance while serving web pages using Apache HTTP Server. It has several filters that automatically optimize files like HTML, CSS, JavaScript, JPEG, PNG and other resources.

As I discussed above that we are using Google‘s repository to install it for future updates, so let’s add the repository to your systems based on your OS architecture.

Step 1: Enabling Google’s mod_pagespeed Repository

Create a file called /etc/yum.repos.d/mod-pagespeed.repo with the help of your favourite editor and add the following lines of code to it based on your OS bit.

RHEL/CentOS/Fedora 32-Bit


RHEL/CentOS/Fedora 64-Bit


Step 2: Installing mod_pagespeed Module for Apache

We use Yum to install the mod_pagespeed on systems, issue below command.

# yum --enablerepo=mod-pagespeed install mod-pagespeed

Step 3: Configuring mod_pagespeed Module for Apache

Above command creates following directories and files.

  • /etc/cron.daily/mod-pagespeed : mod_pagespeed cron script for checking and installing latest updates.
  • /etc/httpd/conf.d/pagespeed.conf : The main configuration file for Apache.
  • /usr/lib/httpd/modules/ : mod_pagespeed module for Apache.
  • /var/www/mod_pagespeed/cache : File caching direcotry for web sites.
  • /var/www/mod_pagespeed/files : File generate prefix for web sites.

Note : No need of additional configuration because mod_pagespeed automatically Turn On.

Step 4: Verifying mod_pagespeed Module for Apache

To verify mod_pagespeed module, first you need to creat a file called phpinfo.php under root directory of Apache and add the following lines of code to it. For example (/var/www/html/phpinfo.php).

Once you created the above file, then restart the Apache service to take new changes. Now access the file phpinfo.php by navigating to your web browser like http://localhost/phpinfo.php or http://IP-your-server/phpinfo.php. You will see “X-Mod-Pagespeed” section in the HTTP header, similar to below.

Install Google Mod_Pagespeed on RHEL, CentOS and Fedora

Install Google Mod_Pagespeed on RHEL, CentOS and Fedora

Step 5: Turning the Module On and Off

If you don’t want to use mod_pagespeed completely, you can Turn Off by editing the following line in pagespeed.conf file (in /etc/httpd/conf.d).

ModPagespeed off

Similarly, to Turn On module:

ModPagespeed on

As I said above after installing mod_pagespeed our website loads 30%-40% faster. We would really like to know about your website speed after installing it on your systems via comments.

0 0 vote
Article Rating
Notify of
1 Comment
Inline Feedbacks
View all comments
clasificados cuba
3 years ago

Hi, I try to enable it but does’nt work

I Have Apache 2.4 CentOS 6


Would love your thoughts, please comment.x