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.8.5/unifi-video.Debian7_amd64.v3.8.5.deb
Install package
sudo dpkg -i unifi-video.Debian7_amd64.v3.8.5.deb
Login to the UniFi Video controller using your web browser and going to the following address to finish configuring the NVR.
https://your-server-address:7443