Getting started with your own VPS

Sharing what I'm learning about setting up and managing a VPS.

What is a VPS, and why use one?

A VPS (virtual private server) is like a computer in the cloud. You control it and can put anything you want on it. You can store your files, host your apps or website, and do anything your personal computer might do. In my case, my VPS hosts this website, stores my important files and photos, and hosts apps I use frequently, like a dashboard that monitors the air quality in my home or a Jeopardy-inspired daily game. Setting up a VPS is a great way to learn about an operating system like Ubuntu, and makes me less reliant on paid 3rd-party software, like Dropbox or Heroku.

Setting up a VPS

Create an account with Vultr and deploy a new server:

  1. Select "Shared CPU" and the $5 server option. Disable automatic backups for now.
  2. On the next step, select the latest version of Ubuntu as the operating system. Select the "Limited User Login" option.
  3. Click 'deploy' and grab a coffee while Vultr sets up your new server!

What have we just done? We have set up a brand new server in the cloud which will have its own IP address. The IP address of the server can be found on your dashboard, for example 66.135.12.142. Now we only need to connect to the server to start interacting with it.

We connect to the server using SSH. You can find the username (in this case it should be linuxuser) and password for logging in on the server's details page. Open a terminal (on Mac) or Command Prompt/PowerShell (on Windows) and type in ssh linuxuser@66.135.12.142 and enter the password when prompted. Of course your IP address will be different than the one I'm using in the example here.

If successful, you'll see some welcome text and be presented with an interactive session on the server, like linuxuser@vultr:~$.

The first step is to run sudo apt update && sudo apt upgrade to update the system software.

Let's get right to using our server as our personal homepage.

Since we'll be adding subdomains and hosting apps, we'll install Nginx as our web server.

sudo apt install nginx 
sudo systemctl start nginx 
sudo systemctl enable nginx

Ubuntu enables ufw (firewall) by default with only SSH (port 22) allowed when you select "Limited User Login" on Vultr. Therefore we must first run sudo ufw allow 80 which allows users to access the site via a browser.

Now enter the IP address of your server into a browser and you should see the default welcome page for Nginx.

Let's create a simple page to replace the Nginx default page.

Run sudo vim /var/www/html/index.html and paste the following content in:

<!DOCTYPE html>
<html>
<head>
    <title>Hello from my new server!</title>
</head>
<body>
    <h1>Hello World!</h1>
    <p>My Nginx server is working!</p>
</body>
</html>

Save and quit by typing :wq and pressing enter. Refresh the page and you should see your new page!

Bookmark the Vim Cheat Sheet for future reference.

Connecting a custom domain to a server

If you don't already have a domain, purchase one on Namecheap.

Navigate to the Advanced DNS section and add the following record:

Type Host Value TTL
A Record @ your ip address here Automatic

Now when you visit your domain, it should point to your VPS!