How to Set Up Your First VPS Server: Complete Step-by-Step Walkthrough for Beginners

So you have decided to get a VPS. Good call. A Virtual Private Server gives you root access, dedicated resources, and the freedom to configure everything exactly how you want it — without the $200+/month price tag of a dedicated server. But if you have never set one up before, the terminal can be intimidating. This walkthrough shows you exactly how to provision, connect to, and secure your first VPS, then get a web server running. Each step includes the actual commands you need to type and explains what they do so you understand the process, not just copy-paste.

Before we begin, you will need a VPS instance. You can compare VPS hosting plans on our site to find a provider that fits your budget. Most providers offer plans starting at $5–$10/month, which is more than enough for learning and hosting a personal website.

Step 1: Choose a Provider and Deploy Your VPS

Before any commands, you need a VPS instance. Most providers make this straightforward. After signing up, you will typically choose an OS image (Ubuntu 24.04 LTS is recommended for beginners — it has the longest support window and the largest community for troubleshooting), a plan (1 vCPU, 1–2 GB RAM is plenty to start), and a data center region close to your target audience.

Once deployed, the provider gives you an IP address and either a root password or an SSH key pair. If they offer SSH key setup during provisioning, always use it — it is more secure than password authentication and saves you from typing credentials every time you connect.

Step 2: SSH Into Your Server

Open a terminal on your local machine. If you are on Windows, use PowerShell or install Windows Terminal. If you are on macOS, the built-in Terminal app works perfectly. Connect to your VPS with:

ssh root@YOUR_SERVER_IP

Replace YOUR_SERVER_IP with the IP address from your provider. If you set up an SSH key, authentication happens automatically. If you are using a password, you will be prompted for it.

The first time you connect, you will see a warning about the host key authenticity. Type yes to continue — this adds the server to your known hosts file and will not appear again unless the server fingerprint changes.

Step 3: Update the System

Even on a fresh VPS, packages may be outdated. Run these commands immediately after first login:

apt update && apt upgrade -y

This updates the package list (apt update) and installs all available upgrades (apt upgrade -y). The -y flag automatically answers yes to any prompts. On Ubuntu 24.04, expect this to take 30–60 seconds on a standard VPS plan. Run this regularly — at least once a week — to stay on top of security patches.

Step 4: Create a Non-Root User

Working as root is convenient but dangerous. A typo like rm -rf / var (note the accidental space) destroys your entire system. Create a regular user with sudo privileges:

adduser yourusername
usermod -aG sudo yourusername

Replace yourusername with your chosen username — something like deploy or admin works well. The first command creates the user and prompts for a password (pick a strong one — at least 12 characters with mixed case and numbers). The second adds them to the sudo group.

Step 5: Configure SSH Key Authentication

Password-based SSH is vulnerable to brute-force attacks. Bots scan the internet constantly for SSH servers and try thousands of passwords per minute. Set up key-based authentication for your new user. On your local machine, generate an SSH key pair if you do not already have one:

ssh-keygen -t ed25519 -C "[email protected]"

The -t ed25519 flag uses the Ed25519 algorithm — it is faster and more secure than RSA. The -C flag adds a comment so you can identify this key later.

Then copy the public key to your server:

ssh-copy-id yourusername@YOUR_SERVER_IP

Now log out (type exit) and test logging in with your new user: ssh yourusername@YOUR_SERVER_IP. If it connects without a password prompt, everything is configured correctly.

Step 6: Harden SSH Configuration

Edit the SSH daemon config to disable root login and password authentication:

sudo nano /etc/ssh/sshd_config

Find and change these lines:

PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes

Restart SSH to apply changes:

sudo systemctl restart sshd

Important: Keep your current SSH session open while testing a new one in another terminal. If something goes wrong, you can still fix it from the original session.

Step 7: Set Up a Firewall

UFW (Uncomplicated Firewall) makes iptables configuration simple. Allow SSH and HTTP/HTTPS traffic, then enable the firewall:

sudo ufw allow OpenSSH
sudo ufw allow 'Nginx Full'
sudo ufw enable
sudo ufw status

The status command confirms your rules are active. Only SSH (port 22) and web traffic (ports 80 and 443) should be allowed by default.

Step 8: Install and Test a Web Server

Install Nginx to serve web content:

sudo apt install nginx -y
sudo systemctl enable nginx
sudo systemctl start nginx

Open your browser and navigate to http://YOUR_SERVER_IP. You should see the Nginx welcome page. If you do, congratulations — your VPS is live and serving web traffic.

To verify Nginx is running and will restart automatically on reboot, check its status:

sudo systemctl status nginx

The output should show active (running) and enabled.

Step 9: Basic Monitoring and Maintenance

Set up automatic security updates so critical patches install without manual intervention:

sudo apt install unattended-upgrades -y
sudo dpkg-reconfigure --priority=low unattended-upgrades

Select “Yes” when prompted. This configures automatic installation of security updates.

Also set up a simple health check. Add this to your crontab with sudo crontab -e:

*/5 * * * * curl -s -o /dev/null -w "%{http_code}" http://localhost | grep -q "200" || echo "Nginx check failed at $(date)" >> /var/log/healthcheck.log

Next Steps

From here, you can configure virtual hosts to serve multiple websites, install a database (MySQL/MariaDB), set up PHP-FPM for dynamic content like WordPress, or deploy application containers with Docker. The same VPS that costs $5–$15/month can handle multiple websites, a development environment, a personal VPN, or a small-scale application server.

See our VPS performance benchmarks to compare how different providers handle real workloads before scaling up your deployment. Remember to set up regular updates (sudo apt update && sudo apt upgrade -y weekly), monitor disk usage with df -h, check running processes with htop, and review logs in /var/log/ periodically.

Leave a Reply