Tutorials  /  Linux Basics

How to Compile and Install Nginx with PageSpeed Module on Debian 8

Ccentron Redaktion · May 2025 ·4 min read ·Linux Basics, Tutorial

This guide explains how to manually compile and install the Nginx mainline version directly from the official Nginx sources, integrating the PageSpeed module. This module boosts website performance using various filters that optimize HTML, images, CSS, and JavaScript.

Prerequisites

  • A server instance running Debian 8.
  • An active sudo user account.
VM

Matching infrastructure at centron

No hardware needed to follow along: ccloud³ VMs with full root access start at €3.12 per month, billed by the hour and ready in seconds. Rent a cloud server →

Manual Installation Process

System Update

Begin by updating the system packages.

Console
sudo apt-get update
sudo apt-get dist-upgrade

Install Required Dependencies

Install the necessary software packages for compiling Nginx and PageSpeed.

Console
sudo apt install build-essential ca-certificates zlib1g-dev libpcre3 libpcre3-dev tar unzip libssl-dev

Download and Extract ngx_pagespeed

Set a variable for the latest PageSpeed module version.

Code
NPS_VER=1.13.35.2

Proceed to download and unpack the ngx_pagespeed source code.

Console
cd /opt
wget https://github.com/pagespeed/ngx_pagespeed/archive/v${NPS_VER}-beta.zip
unzip v${NPS_VER}-beta.zip
rm v${NPS_VER}-beta.zip
cd ngx_pagespeed-${NPS_VER}-beta
psol_url=https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}.tar.gz
[ -e scripts/format_binary_url.sh ] && psol_url=$(scripts/format_binary_url.sh PSOL_BINARY_URL)
wget ${psol_url}
tar -xzvf $(basename ${psol_url})
rm ${NPS_VER}-x64.tar.gz

Compiling and Installing Nginx

Define Nginx Version

Set a variable for the current Nginx version.

Code
NGINX_VER=1.9.9

Alternatively, fetch it dynamically from the official Nginx changelog.

Code
NGINX_VER=$(curl -s http://nginx.org/en/CHANGES | awk 'NR==2' | awk '{print $4}')

Download and Prepare Nginx Source

Download and extract the Nginx source files.

Console
cd /opt
wget -qO- http://nginx.org/download/nginx-${NGINX_VER}.tar.gz | tar zxf -

Configure Nginx with PageSpeed Module

Configure Nginx with multiple modules, including ngx_pagespeed, and define build paths.

Console
cd nginx-${NGINX_VER}
./configure \
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--user=nginx \
--group=nginx \
--without-http_ssi_module \
--without-http_scgi_module \
--without-http_uwsgi_module \
--without-http_geo_module \
--without-http_map_module \
--without-http_split_clients_module \
--without-http_memcached_module \
--without-http_empty_gif_module \
--without-http_browser_module \
--with-threads \
--with-file-aio \
--with-http_ssl_module \
--with-http_v2_module \
--with-ipv6 \
--with-http_mp4_module \
--with-http_auth_request_module \
--with-http_slice_module \
--add-module=/opt/ngx_pagespeed-release-${NPS_VER}-beta

Compile and Install Nginx

Compile the Nginx source code by executing the following command.

Code
make -j $(nproc)

Proceed with the installation of Nginx.

Code
make install

To confirm that the ngx_pagespeed module has been successfully added to your Nginx installation, run the following command.

Code
/usr/local/nginx/sbin/nginx -V

Automatic Installation

You can use an automation script that simplifies the installation process, including the addition of the PageSpeed module.

Download the Script

Retrieve the script using wget.

Console
wget --no-check-certificate https://raw.githubusercontent.com/Qoraiche/nginx-including-pagespeed/master/nginx-autoinstall.sh -O nginx-autoinstall.sh

Make the Script Executable

Set the appropriate permissions for the script.

Console
chmod +x nginx-autoinstall.sh

Execute the Script

Run the script to complete the automated installation.

Code
./nginx-autoinstall.sh

At this point, the installation of the Nginx PageSpeed module is successfully completed.

Conclusion

By compiling Nginx manually and integrating the PageSpeed module, you gain full control over your server's performance optimization. Whether you choose the manual method or the automated script, both approaches ensure a powerful and efficient Nginx installation. Your server is now ready to deliver faster content and an improved user experience, thanks to the advanced capabilities of the PageSpeed module.

Jetzt 200 € Guthaben sichern

Testen Sie Ihr Setup auf ccloud³

Registrieren Sie sich in der ccloud³ und erhalten Sie 200 € Startguthaben für Ihr Projekt – z. B. für eine PostgreSQL-VM mit automatischen Backups.

centron Redaktion Technische Redaktion

Das Redaktionsteam von centron schreibt Anleitungen aus dem Betriebsalltag: getestet auf unserer eigenen Plattform, betrieben im Rechenzentrum in Hallstadt bei Bamberg.

Kategorie Linux Basics
Teilen
Noch offene Fragen?

Unser Team hilft Ihnen bei Ihrem konkreten Setup weiter – von Menschen, die die Plattform selbst betreiben.

War dieses Tutorial hilfreich?

Ihre Antwort wird anonym gespeichert und hilft uns, die Tutorials zu verbessern.

Kommentare

Noch keine Kommentare – stellen Sie die erste Frage zu diesem Tutorial.

Zum Kommentieren anmelden

Kommentare stehen centron-Kunden offen. Melden Sie sich in Ihrem Konto an, um eine Frage zu diesem Tutorial zu stellen.

Weiterlesen

Das könnte Sie auch interessieren

Jetzt kostenlos anfangen

Melden Sie sich an und erhalten Sie in den ersten 60 Tagen ein Guthaben von 200 € bei centron.

Dieses Werbeangebot gilt nur für neue Konten. Angebot ausschließlich für Gewerbetreibende.

Jetzt loslegen Sales kontaktieren