My preferred way of installing and managing software on Ubuntu is compiling the source to /opt and then installing it to the system with the Debian/Ubuntu Update Alternatives system:
- https://wiki.debian.org/DebianAlternatives
- http://manpages.ubuntu.com/manpages/trusty/man8/update-alter...
It allows you to install multiple different versions side-by-side and toggle which of them is called by the canonical system command in /bin, /usr/bin or wherever.
You install them in /opt or somewhere else where collisions won't occur, then use the update-alternatives command to link them into /bin, /usr/bin or other system directories.
It takes a little more work up front, but is worth it. It makes both upgrades and rollbacks completely painless, and you get to decide which version you use.
The upfront work part is in scripting the various binaries and manpage files that need to be linked together, atomically, into system directories. Here's an old (out-of-date) example script for installing Haskell Platform after building it in /opt/ that demonstrates this. All subcommands must be slaved to the main command, and update-alternatives enables this.
https://pastebin.com/74JAxdTX