VPS Setup Guide: Ubuntu Server from Scratch (Complete Tutorial)

December 18, 2025 8 min read VPS Hosting

Complete Ubuntu VPS Setup

Setup a production-ready Ubuntu VPS in 30 minutes.

Step 1: Initial Server Access

ssh root@your_server_ip

Step 2: Update System

apt update && apt upgrade -y
apt install ufw fail2ban -y

Step 3: Create New User

adduser yourusername
usermod -aG sudo yourusername

Step 4: Setup SSH Keys

On your local machine:

ssh-keygen -t rsa -b 4096
ssh-copy-id yourusername@your_server_ip

Step 5: Secure SSH

Edit /etc/ssh/sshd_config:

PermitRootLogin no
PasswordAuthentication no
Port 2222  # Change from default 22
systemctl restart sshd

Step 6: Configure Firewall

ufw allow 2222/tcp  # SSH
ufw allow 80/tcp    # HTTP
ufw allow 443/tcp   # HTTPS
ufw enable

Step 7: Install Web Server

# Nginx
apt install nginx -y
systemctl start nginx
systemctl enable nginx

# Or Apache
apt install apache2 -y
systemctl start apache2
systemctl enable apache2

Step 8: Install PHP

apt install php8.1-fpm php8.1-mysql php8.1-curl php8.1-gd php8.1-mbstring php8.1-xml php8.1-zip -y

Step 9: Install MySQL

apt install mysql-server -y
mysql_secure_installation

Step 10: Install SSL (Let's Encrypt)

apt install certbot python3-certbot-nginx -y
certbot --nginx -d yourdomain.com -d www.yourdomain.com

Step 11: Setup Automatic Updates

apt install unattended-upgrades -y
dpkg-reconfigure -plow unattended-upgrades

Step 12: Configure Fail2Ban

Edit /etc/fail2ban/jail.local:

[sshd]
enabled = true
port = 2222
maxretry = 3
bantime = 3600

Monitoring & Maintenance

# Check system resources
htop

# Check disk usage
df -h

# Check logs
tail -f /var/log/nginx/error.log

Prefer Managed VPS?

WebHostWare Managed VPS includes:

  • Pre-configured LAMP/LEMP stack
  • Automatic security updates
  • 24/7 server monitoring
  • Free SSL certificates
  • cPanel/WHM included
  • Expert support team

Need Help?

WebHostWare offers 24/7 expert support with all hosting plans. Get help when you need it.