❤️ AZDIGI has officially updated to a new blog system. However, some posts may have incorrect or mismatched images. Please click the Report article button at the bottom of the post so AZDIGI can update as quickly as possible. Thank you!

In this article, AZDIGI will help you install mod_pagespeed into Apache on the DirectAdmin server.

I. Introduction

Mod_pagespeed is an open-source Apache HTTP (or Nginx) Server module that automatically applies selected filters to pages and related content such as style sheets, JavaScript and HTML files, as well as images and related site cache requirements.

A key advantage of this module is that it requires no modification of existing content or workflow, which means all internal optimizations and file changes are done on the server, showing modified files directly to users accessing the website.

II. Install mod_pagespeed into Apache on the DirectAdmin server

To install mod_pagespeed into Apache on the DirectAdmin server, we follow these 2 steps.

Step 1: SSH into your server

To install mod_pagespeed into Apache on the DirectAdmin server, we first need to SSH or access your VPS/server with root privileges. Or at least log in to the server with a user with sudo privileges. If you don’t know how to SSH into your VPS/Server, you can refer to the following tutorial:

After successfully SSH, we continue with step 2 to execute the commands to install mod_pagespeed into Apache.

Step 2: Commands to install mod_pagespeed into Apache on the DirectAdmin server

The commands to install mod_pagespeed into Apache on the DirectAdmin server are relatively long, I will divide them into sections for you to follow easily.

First, we will download the mod_pagespeed module and install it with the following commands:

AZDIGI Tutorial
mkdir -p /root/mod_pagespeed
cd /root/mod_pagespeed
wget -O mod-pagespeed-stable_current_x86_64.rpm https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_x86_64.rpm
yum install cpio -y
rpm2cpio mod-pagespeed-stable_current_x86_64.rpm| cpio -idmv
    

The following are images during the execution of these commands.

Install mod_pagespeed into Apache on DirectAdmin
Install mod_pagespeed into Apache on DirectAdmin

Next, we replace the necessary files with the following commands:

AZDIGI Tutorial
mv -f ./etc/httpd/conf.d/pagespeed.conf /etc/httpd/conf/extra/pagespeed.conf
mv -f ./etc/httpd/conf.d/pagespeed_libraries.conf /etc/httpd/conf/extra/pagespeed_libraries.conf
mv -f ./usr/bin/pagespeed_js_minify /usr/bin/pagespeed_js_minify
mv -f ./usr/lib64/httpd/modules/mod_pagespeed_ap24.so /usr/lib/apache/mod_pagespeed_ap24.so
mkdir -p /var/cache/mod_pagespeed
mkdir -p /var/log/pagespeed
    

And here is the image when I run it:

Install mod_pagespeed into Apache on DirectAdmin

Continue to replace the path /usr/lib64/httpd/modules/ with /usr/lib/apache/ in /etc/httpd/conf/extra/pagespeed.conf with the command below:

AZDIGI Tutorial
perl -pi -e 's|/usr/lib64/httpd/modules/|/usr/lib/apache/|g' /etc/httpd/conf/extra/pagespeed.conf
    

After running the replacement command above, we edit the file /etc/httpd/conf/extra/httpd-includes.conf and add the following 2 lines of configuration:

AZDIGI Tutorial
Include /etc/httpd/conf/extra/pagespeed.conf
Include /etc/httpd/conf/extra/pagespeed_libraries.conf
    

By default, this file will have no content at all.

Finally, we restarted the Apache service.

AZDIGI Tutorial
service httpd restart
    

So we have installed mod_pagespeed into Apache complete.

To check if the websites on this server have Mod_pagespeed enabled, we use the following command:

AZDIGI Tutorial
curl -Is tenmien.com  | grep X-Mod-Pagespeed
    

Remember to replace tenmien.com with a domain running on your VPS.

You will get the following result:

AZDIGI Tutorial
X-Mod-Pagespeed: 1.13.35.2-0
    

Here are my results:

Install mod_pagespeed into Apache on DirectAdmin

III. Summary

Hopefully, this article will help websites on your DirectAdmin server significantly increase Google Page Speed score.

Wishing you success. See more useful articles about DirectAdmin at the following link:

If you need assistance, you can contact support in the ways below:

Share:
This article has been reviewed by AZDIGI Team

About the author

Thạch Phạm

Thạch Phạm

Đồng sáng lập và Giám đốc điều hành của AZDIGI. Có hơn 15 năm kinh nghiệm trong phổ biến kiến thức liên quan đến WordPress tại thachpham.com, phát triển website và phát triển hệ thống.

10+ years serving 80,000+ customers

Start your web project with AZDIGI