I recently decided to build ngx_pagespeed for Ubuntu’s stock nginx, since nginx supports dynamic modules (as Apache did long ago) since 1.9.11. Being “dynamic” means that third-party modules don’t have to be built into the main nginx binary, instead can be separately built and dynamically load at runtime, as long as the module and main nginx are compatible, meaning their configuration parameters are similar enough.
（中文版请参见另一篇文章：为 Ubuntu 官方源的 nginx 单独编译 ngx_pagespeed 模块）
I have not seen anyone else build any third-party modules separately. nginx.org official repository provides several modules as packages, but I believe they are built along with the binary they shipped. A probable reason is that even though modules built separately can be loaded, they are not guaranteed to work smoothly. I saw that nginx 1.11.5 is trying to improve compatibility of dynamic modules, but whether that works remains to be tested.
I used the latest Debian (Ubuntu) packaging tools and formats to build the package, and Launchpad PPA to host the apt repository.
- PPA repository: https://launchpad.net/~du9l/+archive/ubuntu/ngx-pagespeed
debianfolder: (TODO – Provide a GitHub repository)
You can use the apt commands shown on the page to enable the PPA and install the packages. The following is an example:
sudo add-apt-repository ppa:du9l/ngx-pagespeed sudo apt-get update
To use this module, first install the right flavored package, then add the line:
… to your
/etc/nginx/nginx.conf file before reloading nginx.
Please remember that this is an experimental feature, and you should NOT use it in production. More information can be found in the PPA description below.
This repository contains “ngx_pagespeed” dynamic module for Ubuntu’s stock nginx packages, including all flavors available in the official repository.
* WARNING: Building dynamic modules alone is EXPERIMENTAL. It is NOT guaranteed to work by the nginx authors. Even though the module can be loaded and has been tested on my own server, I still don’t recommend using it in PRODUCTION environments. USE AT YOUR OWN RISK. *
The package names are “ngx-pagespeed-nginx-FLAVOR” where FLAVOR is core / light / full / extras, which should match your nginx flavor. Check with:
$ dpkg -l | grep nginx
The versions follow ngx_pagespeed’s latest stable versions and Ubuntu’s REL-updates (e.g. xenial-updates) nginx versions. For example, the first version available in this PPA is built with ngx_pagespeed 22.214.171.124 and xenial-updates’ nginx 1.10.0-0ubuntu0.16.04.4 versions.
To use this module, first install the right flavored package, and then add the line:
… to your /etc/nginx/nginx.conf file before reloading nginx.
* NOTE: This package is linked against the pre-built “psol” binaries provided by Google, so only i386 and amd64 systems are supported for now. In the future I will update the package to build psol itself. *