This is a tutorial about how to set up a VPS on Linode. By the end, you should be able to "spin up" a server that is ready to serve your applications to the world!
When things go wrong, don't forget to take a step back and think about what you're doing (beyond just copying and pasting commands). See if there are things you can do to verify the previous steps you have taken worked and read the documentation. Remember, fixing unexpected problems is a part of the process.
The first step to self hosting a project is to get a virtual privat server to deploy on. I use Linode because it's cheap and has a good CLI tool. You can set up your projects on most any VPS, and the steps will be mostly the same, but beginners may choose to use Linode and follow these steps exactly for the first time.
I will use the CLI because it's much easier to write down a list of commands to run and copy and paste them later than to remember which buttons to click. It will also help with automating the process or creating a VPS witch you may want one day.
The CLI docs are here: https://github.com/linode/linode-cli/wiki/Installation
and the GitHub link: https://github.com/linode/linode-cli
Your OS
If you are using Windows, I strongly recommend using WSL (Windows Subsystem for Linux). It will let you use Linux commands from your Windows computer.
Here are the docs from Microsoft: https://learn.microsoft.com/en-us/windows/wsl/install.
If you are useing macOS or Linux, the commands should be the same as what I use here.
SSH keys
After you create the VPS, you will need to connect to it so you can run your application on it. For this, you will need SSH keys so the server knows who you are. So let's create some now!
Create ssh keys with these commands:
ssh-keygen -t ed25519 -C "your_email@example.com"
You can look at the key to make sure it was created:
cat ~/.ssh/id_ed25519.pub
Note: The ssh key is like a password. Don't share it!
Set up the CLI
Now that you have your ssh keys, we can work on getting the VPS. First, go to Linode and create an account.
Then go to your terminal.
Install the CLI tool:
pip3 install linode-cli
Then configure the tool
linode-cli configure
This will open a browser and ask you to log in with the account you created.
Using the CLI to create the VPS
Linode calls a VPS a "linode".
The base command you will use is linode-cli. Commands that have to do with linodes(VPSs) will be followed by the linodes sub-command and then any other arguments you need to pass. So the commands you will use will look something like linode-cli linodes do-something.
When creating a VPS you will need to say what region it should be in and what type of VPS it is. The region is where the server is physically located in the world. The type determines how much RAM and CPU you will get (more RAM costs more money).
You will also want to provide the image and authorized_keys. The image is the operating system the VPS will use, and the authorized_keys is the ssh key we created before.
To see the VPSs (Linodes) use:
linode-cli linodes list
You should see that you have no VPSs yet.
To see the possible regions, use:
linode-cli regions list
Note: We use regions not linodes because the possible regions a VPS can be in are separate from the VPS itself.
To see the possible types, use:
linode-cli linodes types
In this example, I'll use
us-lax
g6-nanode-1
The command to create a VPS is linode-cli linodes create followed by all the parameters you want to pass:
linode-cli linodes create --type g6-nanode-1 --region us-lax --image linode/ubuntu24.04 --label project1 --authorized_keys "$(cat ~/.ssh/id_ed25519.pub)"
Note for the curious:
Using $(command) evaluates a command, letting you use it as input for another command. So $(cat ~/.ssh/id_ed25519.pub) gets turned into the ssh key we created.
Now you can look at your linodes again and see what has been created. You should see the new linode, along with its ip, id, and status. If the status says pending or creating, just wait and run the command again. It could take a few minutes.
Connection to the server
To ssh into your server, use the following commands:
ssh root@server-ip
Where server-ip is the ip of your server (3-digit numbers separated by dots).
You will need to type yes, then you will be connected to the VPS terminal.
You can try running htop to see cpu and ram usage if you want.
To keep your site up you will need to continue to pay linode 5$/month. If you are just testing, you will want to delete the VPS to save money. To do this, use:
linode-cli linodes delete vps-id
Where vps-id is the id of you VPS, witch you can get from listing the VPSs you have.
Congratulations! You now know how to create a VPS that's ready to host your applications.
shameless plug: If you want personal tutoring on anything I write about (or if you want to hire me as a dev) you can contact me at gaspersscottma@gmail.com.
my personal website: https://max-gaspers-scott.team-stingray.com/
Top comments (0)