1) Login to your local Unifi portal and make sure to make a backup (via Maintenance)
2) sudo apt remove unifi
3) sudo apt auto-remove (optional, this is to clean packages that are not in use)
4) sudo vim /etc/apt/sources.list (or use your favourite text editor)
At this point, you should see your previous one: deb http://www.ubnt.com/downloads/unifi/debian stable ubiquiti
Replace the word STABLE for UNIFI5. Now it should be like this: deb http://www.ubnt.com/downloads/unifi/debian unifi5 ubiquiti
Exit and Save
5) sudo apt-key adv --keyserver keyserver.ubuntu.com --recv C0A52C50
6) sudo apt update
7) sudo apt install unifi
Login to your local Unifi portal and you should have version 5!