Linux

How to Install and Configure the mod_pagespeed Module with Apache on Ubuntu 20.04 LTS

How to Install and Configure the mod_pagespeed Module with Apache on Ubuntu 20.04 LTS

A slow website is the main problem faced by most webmasters. You can speed up your website with the help of the mod_pagespeed module. mod_pagespeed is an open-source Apache module created by Google that is used to optimize web pages automatically. This module will compress javascript, CSS, JPEG, PNG, and other resources, and also optimize the length of these files. Currently, this module is used by many hosting providers including, GoDaddy, EdgeCast, DreamHost, and many more.

In this tutorial, we will explain how to install the mod_pagespeed module for Apache on an Ubuntu 20.04 server.

Precondition

  • The server runs Ubuntu 20.04 with a minimum of 4 GB RAM.
  • The root password is configured on your server.

Install Apache Webserver

First, you must install the Apache web server on your system. You can install it using the following command:

apt-get install apache2 -y

After Apache is installed, you can continue to the next step.

Install the Mod_pagespeed Apache Module

You can download the latest mod_pagespeed module by running the following command:

wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_amd64.deb

After downloading, install the downloaded file by running the following command:

dpkg -i mod-pagespeed-stable_current_amd64.deb

After installing the mod_pagespeed module, restart the Apache service to apply the changes:

You can now verify the installation of the mod_pagespeed module with the following command:

curl -D- http://localhost | head

You should see that the mod_pagespeed module is activated on the following output:

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0HTTP/1.1 200 OK
Date: Thu, 25 Jun 2020 09:44:02 GMT
Server: Apache/2.4.41 (Ubuntu)
Accept-Ranges: bytes
X-Mod-Pagespeed: 1.13.35.2-0
Vary: Accept-Encoding
Cache-Control: max-age=0, no-cache, s-maxage=10
Content-Length: 10117
Content-Type: text/html; charset=UTF-8

100 10117  100 10117    0     0  1975k      0 --:--:-- --:--:-- --:--:-- 2469k

If you want to disable the mod_pagespeed module, edit the pagespeed.conf file:

nano /etc/apache2/mods-available/pagespeed.conf

Change the following lines:

ModPagespeed off     #To turn off mod_pagespeed

Save and close the file then restart the Apache service to apply changes.

systemctl restart apache2

Configure the Mod_pagespeed Admin Interface

The Apache Mod_pagespeed module provides a web-based admin interface to view server status. By default, this can only be accessed from localhost. So, you have to configure it to access from a remote host. You can do this by editing the /etc/apache2/mods-available/pagespeed.conf file:

nano /etc/apache2/mods-available/pagespeed.conf

Add “Allow of all” sections in the and sections:

<Location /pagespeed_admin>
    Order allow,deny
    Allow from localhost
    Allow from 127.0.0.1
    Allow from all
    SetHandler pagespeed_admin
</Location>

<Location /pagespeed_global_admin>
    Order allow,deny
    Allow from localhost
    Allow from 127.0.0.1
    Allow from all
    SetHandler pagespeed_global_admin
</Location>

Save and close the file then restart the Apache service to apply changes:

systemctl restart apache2

Mod_pagespeed Web Interface Access

Now, open your web browser and type the URL http: // your-server-ip / pagespeed_admin. You will see the Mod_pagespeed dashboard in the following screen:

1

Chart

2

Statistics

3

Conclusion

In the tutorial above, you learned how to install the mod_pagespeed Apache module on an Ubuntu 20.04 server. Now, your website loads 40% -50% faster. For more information, visit the mod_pagespeed documentation.

Related posts

How to Install R on Ubuntu 20.04

Linux

How to ZSH and Oh-my-zsh Settings on Linux

Linux

How to Install Ruby On Rails on Ubuntu 20.04

Linux

How to Make a Bootable Linux USB Drive Using Linux

Howto

How to Install Nginx with PHP and MySQL (LEMP Stack) on Ubuntu 20.04 LTS

Linux

How Linux makes data recovery easy

Linux

How to Install TensorFlow on Ubuntu 20.04

Linux

How to Install Gradle on Ubuntu 20.04

Linux

How to install Steam and activate Proton on Fedora

Linux