For Raspberry Pi, see this YouTube video.

For VPS, check out this page. And also make sure to follow part 2 for securing your masternode.