Forum archive
Upgrade nginx to 1.17.4
Hi guys,
The version of nginx that comes on your LEMP stack is 1.10, and an apt-get upgrade did not show any updates available. I've recently added the official nginx repo by adding this to my apt sources:
deb http://nginx.org/packages/mainline/debian/ stretch nginx
I have a fully functioning setup now, however I want to use a WordPress plugin called Nginx Helper to purge the cache, however it doesn't seem to be working using the "Delete local server cache files."
I did some research - I need the use the ngx_cache_purge module. But when I try to install libnginx-mod-http-cache-purge, I get the following error:
root@nginx-php-fastcgi .../nginx/sites-enabled# apt install libnginx-mod-http-cache-purge Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation:
The following packages have unmet dependencies: libnginx-mod-http-cache-purge : Depends: nginx-common (= 1.10.3-1+deb9u3) but it is not going to be installed E: Unable to correct problems, you have held broken packages.
Obviously it's looking for the old nginx version dependency. Any idea how I can resolve this?
apt-get install nginx-extras wants to install the module, but uninstall the current version of nginx that I have running, and downgrade me back to 1.10.
Thanks!
Is there is a particular feature that you need from a newer version? Or do you just want a "bleeding edge" version because it's new and shiny?
At risk of "over explaining"; Debian "stable" focuses on stability and security, rather than "latest and greatest" (aka "new and shiny"). It maintains stability by "freezing" the versions of software when a stable version is released. Other than rare specific circumstance, instead of updating the version to address bugs and security issues for the lifecycle of the stable OS release, security fixes are backported (and auto installed in TurnKey) and bugs are patched in the "frozen" version.
That process provides stability via the knowledge that the application APIs will be completely stable for the whole life of the OS. It also means that all the software has been tested with all the other software that might likely be installed alongside (including libraries). Security is provided via backported patches as noted above (which are auto installed by TurnKey). The downside is that the software becomes quite dated over time. Although as a general rule, stability is far more important on a server.
So unless there is some specific reason to run a newer version (e.g. a specific feature that the older version doesn't have, or a specific edge case bug which Debian hasn't patched), you are advised to just stick with the version provided by Debian.
So to circle back to your immediate concern; by installing the "mainline" version of Nginx from upstream you now have the latest version. But as you've discovered, there is a price for that. Nginx compile against the specific Debian version, so Nginx itself should be relatively stable and shouldn't break your system (i.e. it's not a "FrankenDebian). But you only get the main application and the precompiled modules that Nginx themselves provide for "free" (in context of effort required). Any other third party modules you want (e.g. 'ngx_cache_purge' - as provided by the 'libnginx-mod-http-cache-purge' Debian package) you'll need to compile from source yourself. You'll also need to recompile them every time that Nginx is updated.
Compiling from source is not the end of the world and is rarely as scary as it sounds. Although in some cases it can be a PITA; and it's a significant additional maintenance overhead. Regardless, if you're interested in pushing ahead with that, you'll need to install the relevant build tools (the 'build-essential' package should generally be enough), download the Nginx source code for the same version as you have installed (AFAIK you don't need to rebuild Nginx itself, but you need to source of the exact same version to compile the module against; and will need to redo this every time you update Nginx). The 'ngx_cache_purge' source code is on GitHub. Google turned up some "how to build" instructions, although I note that they are for installing from a source package on CentOS (rather than Debian) although the gist of that appears to be relevant on face value (although will likely require additional research and a bit of trial and error).
So as per my note above, unless you NEED a newer version of Nginx, downgrading to the version supplied by Debian (i.e. 1.10) is the recommended path. If you do need a specific feature in newer Nginx, then there may still be a better (i.e. less labor intensive) path than using 1.17 and installing your required module from source.
The backports repository (i.e. in the case of TurnKey v15.x; "stretch-backports") has v1.14 (and the module you want). Backports doesn't have security support, so updates won't be auto installed, but any security fixes would also likely be backported (although no guarantee on timeliness).
If you need newer than that, then v1.16 (the latest Nginx "stable" version) is in testing/Bullseye (although again testing has no guarantee of timely security updates). You do need to be a bit careful when installing stuff from testing (as per "FrankenDebian" link above). But assuming that it doesn't pull in too many newer dependencies, it can be done relatively safely via package pinning. I can assist further with that if you want to go that path.
Worst case scenario, compiling from the Debian source package on a Stretch base (essentially how backports are created) is still often easier than compiling from upstream source. That is all somewhat theoretical though and without further research, it's impossible to know how easy (or hard) it might be to install from anything other than backports.
One other option would be to request that v1.16 is backported for Debian 10/Buster (what TurnKey v16.x will be based on) and do a Debian "in place" upgrade to a 10/Buster base OS. You'll need to wait until Nginx is backported though, as currently it's not in buster-backports. As we don't yet have Buster packages built, you won't get any TurnKey package updates yet either, but it should work ok.
As a bit of an aside, it's perhaps also worth clarifying that as of the release of Debian 10/Buster as "stable", Debian 9/Stretch is now "oldstable"; "testing" is the as yet unreleased 11/Bullseye. When Debian "testing" is released as "stable" (roughly every 2 years), the previous "stable" becomes "oldstable" and the previous "oldstable" becomes "oldoldstable".
Anyway, I suspect that I may have inadvertently lulled you into thinking that installing latest versions from upstream isn't that big a deal via my notes re updating Dehydrated (i.e. the Let's Encrypt "nonce" issue). Whilst installing from upstream is ok, the way I advised to do that is generally considered very poor practice and there was a very specific contest to me making that recommendation (and even then, it was a bit of a hack). Dehydrated is a bash script, so only depends on bash. That means virtually no risk of breaking other stuff. And it was to work around an immediate issue. At the time there was no easy and immediate fix other than via a newer Dehydrated version, although incidentally it is now provided via a backported package anyway.
Anyway, sorry about the essay... Let me know which path you plan to go and/or your specific needs and I'm happy to provide further guidance. If you have specific questions, ideas or problems, please feel free to bounce stuff off me... :)