Back to ArticlesTutorial Featured
How to Set Up a VPS: A Step‑by‑Step Tutorial Learn how to choose, provision, secure, and configure a Virtual Private Server (VPS) from scratch with this comprehensive, beginner‑friendly guide.
VPS tutorial setup server cloud Linux
Setting up a Virtual Private Server (VPS) can feel daunting if you’ve never done it before, but with the right guidance it’s a straightforward process. This tutorial walks you through every stage—from picking a provider to securing your new server—so you can have a fully functional VPS up and running in under an hour.
Table of Contents
Choose a VPS Provider & Plan
Create and Access Your VPS
Initial Server Configuration
Secure Your VPS
Set Up a Basic Web Stack (Optional)
Useful Post‑Setup Tips
1. Choose a VPS Provider & Plan
Provider Starting Price (USD/mo) OS Options Notable Features DigitalOcean $4 Ubuntu, CentOS, Debian, Fedora Simple UI, 1‑click apps Linode $5 Ubuntu, Debian, Arch, AlmaLinux High‑performance SSD Vultr $2.5 Ubuntu, CentOS, Rocky Linux Global data‑centers Hetzner (Germany) €3 Ubuntu, Debian, Fedora Excellent price‑to‑performance
What to look for:
CPU & RAM: For a basic web server, 1 vCPU + 1 GB RAM is enough. Scale up as needed.
SSD storage: Faster I/O for databases and web traffic.
Data‑center location: Choose a region close to your target audience for lower latency.
Backup options: Some providers offer automated snapshots—useful for disaster recovery.
Selecting an OS
For beginners, Ubuntu LTS (e.g., 22.04) is the most user‑friendly due to its large community and extensive documentation.
2. Create and Access Your VPS
Sign up for your chosen provider and verify your email.
Create a new droplet/instance :
Choose the OS (Ubuntu 22.04 LTS recommended).
Select the plan you identified earlier.
Pick a data‑center region.
(Optional) Add SSH keys now—this is the most secure way to log in.
Empowering developers with cutting-edge insights and practical tutorials for modern web development.
© 2025 FromTune. All rights reserved.
Launch the instance. You’ll receive an IP address (e.g., 203.0.113.45).Connect via SSH :
ssh root@203.0.113.45
If you didn’t add an SSH key during creation, the provider will email a temporary password. Log in, then immediately change the password with passwd.
Tip: Use a terminal emulator like iTerm2 (macOS) or PuTTY (Windows) if you’re on a desktop.
3. Initial Server Configuration
3.1 Update the System apt update && apt upgrade -y
This ensures you have the latest security patches.
3.2 Create a Non‑Root User Running everything as root is risky. Create a regular user and grant sudo privileges.
adduser alice # replace "alice" with your preferred username
usermod -aG sudo alice
su - alice
sudo whoami # should output "root"
3.3 Harden SSH Edit /etc/ssh/sshd_config:
nano /etc/ssh/sshd_config
Change or add the following lines:
Port 2222 # optional: move away from default 22
PermitRootLogin no
PasswordAuthentication no # if you use SSH keys only
ssh -p 2222 alice@203.0.113.45
4. Secure Your VPS
4.1 Install a Firewall (UFW) apt install ufw -y
ufw default deny incoming
ufw default allow outgoing
ufw allow 2222 /tcp # SSH port you set
ufw allow http
ufw allow https
ufw enable
4.2 Enable Fail2Ban apt install fail2ban -y
systemctl enable fail2ban
Fail2Ban will block repeated failed login attempts.
4.3 Set Up Automatic Updates (Optional but recommended) apt install unattended-upgrades -y
dpkg-reconfigure --priority = low unattended-upgrades
5. Set Up a Basic Web Stack (Optional) If you plan to host a website, the classic LAMP (Linux‑Apache‑MySQL‑PHP) or LEMP (Linux‑Nginx‑MySQL‑PHP) stack works well.
Example: LEMP Stack on Ubuntu # Install Nginx
apt install nginx -y
# Install MySQL (or MariaDB)
apt install mariadb-server -y
# Secure MySQL installation
mysql_secure_installation
# Install PHP and extensions
apt install php-fpm php-mysql -y
# Configure Nginx to use PHP
cat > /etc/nginx/sites-available/example.com << 'EOF'
server {
listen 80;
server_name example.com www.example.com;
root /var/www/html;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
}
}
EOF
ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
nginx -t && systemctl reload nginx
Place your site files in /var/www/html and you’re live.
6. Useful Post‑Setup Tips
Conclusion Setting up a VPS is a valuable skill for developers, sysadmins, and hobbyists alike. By following this tutorial you’ve:
Chosen a provider and launched a server.
Secured SSH and the firewall.
Created a non‑root user with sudo rights.
(Optionally) Deployed a basic web stack.
Implemented essential security measures.
From here you can expand—install Docker, run a Git server, host a game server, or anything else your project demands. Happy hosting!