Below are my build instructions for GnuPG 2.2.10, released on August 30th, 2018. These instructions are built for a headless Ubuntu 18.04 LTS server (and have also been tested on Ubuntu 14.04/16.04). Updated Aug 19, 2022 to run on CentOS 7.9.
If you prefer, you may use the below install script to install GnuPG 2.2.x by running the following commands:
curl -OL "https://gist.githubusercontent.com/colinferm/383fb3890a5e25472b22de9bb6cab767/raw/41c92312093261fe9a9344034a5f1dc7aefe0a67/install-gnupg22.sh" && sudo -H bash ./install-gnupg22.sh