Tested on Ubuntu 14.04 & 16.04, I recommend using the server install image.
(In TERMINAL or ssh as root user)

apt-get update
apt install git
apt install libmicrohttpd-dev libssl-dev cmake build-essential libhwloc-dev
git clone https://github.com/fireice-uk/xmr-stak.git
mkdir xmr-stak/build
cd xmr-stak/build
make install
cd bin

Do you want to use the HTTP interface? Unlike the screen display, browser interface is not affected by the GPU lag. If you don't want to use it, please enter 0, otherwise enter port number that the miner should listen on 0
Please enter the currency that you want to mine: cryptonight_v8
Pool address: e.g. pool.example.com:3333 pool.x-cash.us:3333
Username (wallet address or pool login): Your Wallet Address
Password (mostly empty or x): x
Rig identifier for pool-side statistics (needs pool support). anything
Does this pool port support TLS/SSL? Use no if unknown. n
Do you want to use nicehash on this pool? n
Do you want to use multiple pools? n
and you are done.

To start mining in the future use:
cd xmr-stak/build/bin
nohup ./xmr-stak &

To automatically start on boot and run in background create /root/mine.sh and add this:
if pgrep -x "xmr-stak" > /dev/null
echo "Already running!"
echo "Starting!"
cd /root/xmr-stak/build/bin/
./xmr-stak &

And add this to /etc/crontab:
* * * * * root sh /root/mine.sh