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

Contents

  1. Prerequisites
  2. Manual Installation Process
  3. Compiling and Installing Nginx
  4. Automatic Installation
  5. Conclusion

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.
OPS

Rather have your server managed?

centron takes care of updates, monitoring and troubleshooting: managed servers from €54.04 per month, run in our own data center in Germany. View managed servers →

Prefer to manage it yourself? Cloud servers from €4.04 per month →

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.

Claim €200 credit

Test your setup on ccloud³

Sign up for ccloud³ and receive €200 starting credit for your project.

centron Redaktion Technical editorial team

The centron editorial team writes guides from day-to-day operations: tested on our own platform, run in our data centre in Hallstadt near Bamberg.

Category Linux Basics
Share
Still have questions?

Our team will help you with your specific setup - in German or English, by people who run the platform themselves.

Was this tutorial helpful?

Your answer is stored anonymously and helps us improve our tutorials.

Comments

No comments yet - be the first to ask a question about this tutorial.

Sign in to comment

Comments are open to centron customers. Sign in to your account to ask a question about this tutorial.

Get started for free

Sign up and receive €200 credit at centron within your first 60 days.

This promotional offer applies to new accounts only. Available exclusively to businesses.