How to Set Up a VPS on DigitalOcean: Complete Beginner Guide

✅ Tested with DigitalOcean Droplets running Ubuntu 24.04 LTS — Last updated: June 2026
Setting up a VPS on DigitalOcean is the fastest way to get a Linux server in the cloud. DigitalOcean Droplets (their term for VPS instances) start at $6/month and can be running in under 60 seconds. This guide covers everything: creating your first Droplet, securing it properly, setting up a web server, and running your first applications — including local AI models if you upgrade to a GPU Droplet.
If you want a cheaper starting point, Hostinger VPS offers KVM virtualization with full root access at a lower price than most competitors. Runs Ubuntu 24.04, Debian 12, AlmaLinux and CentOS out of the box — good fit for learning, side projects, or low-traffic servers.
- KVM virtualization — dedicated resources, full root access
- 1 vCPU / 4 GB RAM / 50 GB NVMe SSD from €3.99/month
- Ubuntu 24.04, Debian 12, CentOS, AlmaLinux supported
- Weekly automated backups included
- 1 Gbps network bandwidth
Affiliate disclosure: we earn a small commission if you sign up — at no extra cost to you.
Table of Contents
- Why DigitalOcean
- Create Account and Add SSH Key
- Create Your First Droplet
- First Login and Initial Setup
- Secure Your VPS
- Configure Firewall
- Install a Web Server
- Run Applications with Docker
- GPU Droplets for AI
- Snapshots and Backups
- Troubleshooting
- FAQ
Why DigitalOcean
There are many VPS providers. DigitalOcean is consistently recommended for developers because:
- Simple pricing: Flat monthly rates, no surprise bills. $6/month for 1 vCPU, 1 GB RAM, 25 GB SSD, 1 TB transfer
- Excellent documentation: Their tutorials are among the best technical documentation on the internet
- Fast provisioning: A new Droplet is ready in 55 seconds
- Global data centers: 15 regions worldwide
- Managed databases: Postgres, MySQL, Redis available as managed services
- Clean control panel: Simple enough for beginners, powerful enough for production
Droplet Pricing Overview
| Plan | vCPU | RAM | Storage | Price/month | Best For |
|---|---|---|---|---|---|
| Basic Shared | 1 | 512 MB | 10 GB | $4 | Static sites only |
| Basic Shared | 1 | 1 GB | 25 GB | $6 | Small apps, dev |
| Basic Shared | 2 | 2 GB | 60 GB | $12 | Most web apps |
| General Purpose | 2 | 8 GB | 25 GB | $63 | Production apps |
| GPU (H100) | 8 | 48 GB | 256 GB | ~$600 | AI inference |
Create Account and Add Your SSH Key
- Go to digitalocean.com and create an account
- Add a payment method (credit card or PayPal)
- You get $200 in free credit for 60 days as a new user via their referral program
Generate and Add SSH Key (Do This Before Creating a Droplet)
# On your LOCAL machine — generate SSH key:
ssh-keygen -t ed25519 -C "myemail@example.com"
# Accept defaults (saves to ~/.ssh/id_ed25519)
# View your public key:
cat ~/.ssh/id_ed25519.pub
# Copy this entire line- In DigitalOcean control panel: Settings → Security → Add SSH Key
- Paste your public key, give it a name (e.g., "My Laptop")
- Click Add SSH Key
Always add your SSH key before creating Droplets — this way you can log in immediately without a password.
Create Your First Droplet
- Click Create → Droplets
- Choose an image: Ubuntu 24.04 LTS x64 (recommended for beginners)
- Droplet type: Basic (shared CPU) for development, General Purpose for production
- CPU options: Premium Intel or Regular Intel (Regular is fine for most uses)
- Region: Choose the closest to your users
- Authentication: Select SSH Key and check the key you added
- Hostname: Give it a memorable name (e.g., "myapp-production")
- Click Create Droplet
Your Droplet's IP address appears in the dashboard within 60 seconds.
First Login and Initial Setup
# Log in as root (replace with your Droplet's IP):
ssh root@YOUR_DROPLET_IP
# You'll see something like:
# Welcome to Ubuntu 24.04.1 LTS (GNU/Linux 6.8.0-51-generic x86_64)
# Check system info:
uname -a
free -h
df -hCreate a Non-Root User (Essential)
Running everything as root is dangerous — a single mistake can destroy your server. Create a regular user with sudo access:
# Create user (replace 'deploy' with your preferred username):
adduser deploy
# Give sudo access:
usermod -aG sudo deploy
# Copy root's SSH keys to the new user:
rsync --archive --chown=deploy:deploy ~/.ssh /home/deploy
# Test login in a NEW terminal (don't close current one yet):
ssh deploy@YOUR_DROPLET_IP
# Verify sudo works:
sudo apt updateUpdate the System
sudo apt update && sudo apt upgrade -y
sudo apt autoremove -ySecure Your VPS
Harden SSH Configuration
sudo nano /etc/ssh/sshd_config# Change these settings:
PermitRootLogin no # disable root SSH login
PasswordAuthentication no # key auth only
PubkeyAuthentication yes
MaxAuthTries 3
LoginGraceTime 30sudo sshd -t # test config
sudo systemctl restart sshInstall Fail2ban
sudo apt install fail2ban -y
sudo systemctl enable --now fail2ban
# Check status:
sudo fail2ban-client status
sudo fail2ban-client status sshdConfigure Firewall
Use DigitalOcean's Cloud Firewall (preferred) or UFW on the server itself. Using both is fine.
UFW on the Server
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh # allow SSH (port 22)
sudo ufw allow 80 # HTTP
sudo ufw allow 443 # HTTPS
sudo ufw enable # enable the firewall
sudo ufw status verboseDigitalOcean Cloud Firewall (Better)
In the control panel: Networking → Firewalls → Create Firewall
- Add inbound rules: SSH (port 22), HTTP (80), HTTPS (443)
- Outbound: Allow all
- Apply to your Droplet
Cloud Firewalls block traffic before it reaches your server, which is more efficient than UFW.
Install a Web Server
Nginx (Recommended)
sudo apt install nginx -y
sudo systemctl enable --now nginx
# Allow through UFW:
sudo ufw allow 'Nginx Full'
# Visit your Droplet's IP in a browser — you should see the Nginx welcome pageServe a Static Site
# Create a site:
sudo mkdir -p /var/www/mysite/html
sudo chown -R $USER:$USER /var/www/mysite/html
cat > /var/www/mysite/html/index.html << 'EOF'
Hello from my DigitalOcean VPS!
EOF
# Create Nginx config:
sudo nano /etc/nginx/sites-available/mysiteserver {
listen 80;
server_name yourdomain.com www.yourdomain.com;
root /var/www/mysite/html;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}sudo ln -s /etc/nginx/sites-available/mysite /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginxFree SSL with Let's Encrypt
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
# Auto-renewal is set up automatically. Test it:
sudo certbot renew --dry-runRun Applications with Docker
Docker makes it easy to deploy any application on your Droplet without worrying about dependencies:
# Install Docker:
curl -fsSL https://get.docker.com | bash
sudo usermod -aG docker $USER
newgrp docker
# Example: Run Ollama (local AI models) on your VPS:
docker run -d
--name ollama
-p 127.0.0.1:11434:11434 # bind to localhost only (not public!)
-v ollama_data:/root/.ollama
--restart unless-stopped
ollama/ollama
docker exec -it ollama ollama pull llama3.2
# Forward port to your local machine via SSH tunnel to access it:
# On your local machine:
ssh -L 11434:localhost:11434 deploy@YOUR_DROPLET_IPGPU Droplets for AI Workloads
DigitalOcean offers GPU Droplets with NVIDIA H100 GPUs — the most powerful commercially available GPUs for AI inference. These are expensive ($600+/month) but powerful enough to run 70B parameter models at full speed.
# After creating a GPU Droplet — verify GPU:
nvidia-smi
# Run Ollama with GPU support:
docker run -d
--name ollama
--gpus all
-p 127.0.0.1:11434:11434
-v ollama_data:/root/.ollama
--restart unless-stopped
ollama/ollama
# Pull and run a large model:
docker exec ollama ollama pull llama3.1:70bFor most use cases, RunPod or Lambda Labs offer better GPU pricing for AI inference. But if you're already using DigitalOcean for hosting, GPU Droplets are convenient for keeping everything in one place.
Snapshots and Backups
Automated Backups
Enable in the Droplet settings — DigitalOcean backs up your Droplet weekly for 20% of the Droplet price. For a $6 Droplet, that's $1.20/month for weekly backups.
Manual Snapshots
In the Droplet's control panel: Snapshots → Take Snapshot. The Droplet must be powered off for a consistent snapshot (or use a live snapshot, which DigitalOcean supports).
Snapshots are billed at $0.05/GB/month. A 25 GB Droplet snapshot costs ~$1.25/month.
Troubleshooting
Can't connect via SSH
Use DigitalOcean's Droplet Console (browser-based terminal in the control panel) to access your server even when SSH is broken. From there you can fix your SSH config, undo firewall changes, and recover locked-out situations.
# Check SSH service status via console:
systemctl status ssh
# Check firewall:
ufw status
# Check if SSH is listening:
ss -tulnp | grep :22Ran out of disk space
# Find what's taking space:
df -h
du -sh /var/log /var/cache /home/* 2>/dev/null | sort -rh | head
# Clean apt cache:
sudo apt autoremove && sudo apt autoclean
# Clean Docker:
docker system prune -a
# If you need more space — resize the Droplet in the control panel
# (power off → Resize → select larger plan)High CPU usage
htop # find the process using CPU
# Press F6 to sort by CPU%
# Check system logs for cron jobs, malware mining:
grep "CRON" /var/log/syslog | tail -20
ps aux --sort=-%cpu | head -10Frequently Asked Questions
How much does a basic web app VPS cost on DigitalOcean?
A typical setup for a small production web app: $12/month Droplet (2 vCPU, 2 GB RAM) + $15/month managed PostgreSQL (smallest tier) + free bandwidth up to 2 TB = ~$27/month. Add automated backups for $2.40/month more.
DigitalOcean vs Vultr vs Hetzner — which is cheapest?
Hetzner is the cheapest for raw compute — a 2 vCPU, 4 GB RAM server costs €4.99/month in Europe vs $24/month on DigitalOcean. For US-based users, Vultr is often cheaper than DigitalOcean for equivalent specs. DigitalOcean wins on UX, documentation quality, and managed services ecosystem.
How do I point my domain to my Droplet?
At your domain registrar (Namecheap, GoDaddy, etc.), add an A record pointing your domain to your Droplet's IP address. Or use DigitalOcean's nameservers and manage DNS in their control panel. DNS propagation takes 15 minutes to a few hours.
Can I run multiple websites on one Droplet?
Yes. Nginx supports virtual hosting — you create a config file for each domain in /etc/nginx/sites-available/. Each domain serves from a different directory. One Droplet can host dozens of low-traffic sites. Add each domain to Let's Encrypt separately for free HTTPS.
A DigitalOcean Droplet is the quickest path from code to internet. Once your server is running, check out our guides on setting up Docker and mastering SSH — these two skills are what you'll use every day as a sysadmin or developer working with cloud VPS infrastructure.
