Build and Install Nginx with PageSpeed Support on Debian 8

This step-by-step guide explains how to compile and install the latest mainline version of Nginx from source while integrating Google’s PageSpeed module. The PageSpeed module significantly enhances the performance of web applications by automatically applying intelligent optimizations. It minimizes HTML, compresses JavaScript and CSS files, and improves the delivery of image assets — all of which reduce latency and improve browser rendering. These enhancements are particularly useful for websites aiming to boost user experience, mobile performance, and SEO rankings.

Instead of using default package repositories, this approach provides developers and system administrators with full control over the compilation process. You decide which features and modules are included, allowing a streamlined, lightweight, and high-performing web server tailored to your needs. This guide is ideal for users who need custom builds, performance tuning, or compatibility with specific modules like ngx_pagespeed. By the end of this tutorial, you’ll have a customized Nginx installation optimized for speed and flexibility, ready to serve dynamic, efficient content across a wide range of use cases.

System Requirements

  • A Debian 8 server
  • A sudo-enabled user account

Manual Installation Process

Update System Packages

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

Install Required Dependencies

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

Download ngx_pagespeed and PSOL

NPS_VER=1.13.35.2
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

Set Nginx Version and Download Source

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

Configure, Compile and Install Nginx

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
make -j $(nproc)
make install

Confirm Installation

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

Optional: Automated Script Installation

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

Conclusion

By following this guide, you’ve learned how to manually compile and configure Nginx with the PageSpeed module on a Debian 8 system. This method gives you complete control over which modules are included, ensuring a custom fit for your environment. The resulting setup supports faster load times, improved performance, and better handling of optimized assets for modern websites.

Whether you chose the manual route for granular configuration or opted for the automatic installation script for convenience, you now have a high-performance Nginx instance running with Google’s powerful optimization tools built-in. This configuration is ideal for developers, sysadmins, and DevOps teams looking to maximize efficiency and control. With your server tuned for speed, you’re well-equipped to support demanding applications and deliver top-tier user experiences across all devices.

Source: vultr.com

Create a Free Account

Register now and get access to our Cloud Services.

Posts you might be interested in:

Moderne Hosting Services mit Cloud Server, Managed Server und skalierbarem Cloud Hosting für professionelle IT-Infrastrukturen

Secure HTTPS Setup on Arch Linux with Apache or Nginx

Security, Tutorial

Linux file permissions with this comprehensive guide. Understand how to utilize chmod and chown commands to assign appropriate access rights, and gain insights into special permission bits like SUID, SGID, and the sticky bit to enhance your system’s security framework.