You can run all the commands from the terminal, or ssh into the server
See here if you need to setup SSH on the server.
Install prerequisites
sudo apt-get install mongodb mongodb-server openjdk-8-jre-headless jsvc
Download UniFi Video installer
Note the Debian package works on Ubuntu, and has been tested on the latest Ubuntu
wget https://dl.ubnt.com//firmwares/ufv/v3.9.6/unifi-video.Ubuntu16.04_amd64.v3.9.6.deb
Install package
sudo dpkg -i unifi-video.Ubuntu16.04_amd64.v3.9.6.deb
Login to the UniFi Video controller using your web browser and going to the following address to finish configuring the NVR.
http://localhost:7443