/logs - self-hosting | cloud | setup
A glimpse into my VPS setup flow
EDIT (02/26): well, turns out I needed more automation...
This is just a record of stuff I did while setting up a new VM on Oracle Cloud since AWS is too costly for my personal needs, so maybe if you're new to VPS hosting, you can use this as a reference. Mostly just documentation for myself though :)
Prerequisites:
- Domain name - Even if you plan on having single-user stuff and you're not uncomfortable with seeing IP addresses in your address bar, you need a domain for SSL certs, and those are pretty essential today. Moreover, having a domain can help get around ephemeral IPs, like in Oracle Cloud's free tier - more on that later.
- What's your goal? Projects, personal tools, Minecraft server, portfolio website - what matters is that you have one in mind before you start so that you can work with motivation.
- Cloud provider - There's quite a lot out there. Decisions boil down to factors like cost (AWS is a dangerous $$$ sink if you don't know what you're doing), reliability (Oracle has a bad rep for a reason), ecosystem of services (AWS provides a lot, but maybe you don't need that many), customer support, etc. Do your research before choosing, but keep in mind that vendor lock-in is easier to avoid when it comes to cloud services, so don't dwell on it too much.
First steps:
- Config:
- What do you need?
Is your time worth more than the added expense for managed solutions? Or do you prefer a raw Linux VPS for you to shape and play God's hand with? Answer: It depends, on how much you're ready to work for it. If you have specific needs that are complex by themselves, and you just want to get it up and running, something like AWS RDS might be better and more reliable than running a MySQL instance yourself. But if you're on a learning path, by all means experiment.
- What do you need?
- How much do you need?
CPU cores, RAM, storage, network bandwidth, number of instances, and autoscaling are just some parameters to be considered. Balance these against your cost to arrive at a compromise. - Instance setup:
- Psst: make a script for your SSH connection, to make it easier
- Update your system:
sudo apt update,sudo apt upgrade
Essentials:
- NodeJS (ok not really an essential): I prefer version managers like nvm, since I find dependency management to be irritating, especially when it comes to front-end. Having different versions to test stuff helps.
- Python: Should come pre-loaded on most Linux distros. Essential for easy and modern automation that go beyond basic shell scripting. pyenv is a good version manager I've liked. The in-built venv is good, but excessive in its bloat and redundancy.
- Nginx: Any reverse proxy, really, but nginx is the open-source industry standard, and also doubles as a load balancer. Note: the nginx apt repository is outdated, update it as described.
- certbot: Automatic issual and renewal of SSL certs is a must on any modern server, and certbot leaves you no excuse since it does it for free. Fire-and-forget!
Process managers:
- systemctl: Bit of a learning curve, but very powerful
- pm2: Simple and good process manager for NodeJS processes
Backup solution:
I'm too lazy for a 3-2-1 backup strategy, and I'm not running anything crucial as of now. My backup strategy is just a cronjob that runs daily or weekly to perform a rclone backup of the relevant data to Backblaze.