DEV Community

Amaanullah Khan
Amaanullah Khan

Posted on • Originally published at amaanullah.com

How to Deploy Your Web App Fast & Secure on a VPS (Step-by-Step Guide)

Deploying a web application on a VPS can feel overwhelming, especially if you’re new to server setup, DNS, and security. In this guide, I’ll walk you through the exact steps I use every time I deploy a real project, from server creation to HTTPS setup, so you can deploy yours quickly and securely.

🧠 Why This Matters

Most tutorials either:

  • ✅ focus only on code
  • ❌ ignore real deployment steps
  • ❌ leave out security essentials

This article covers everything you actually need — not just theory but practical hands-on steps.

🪄 Tools & Requirements

Before we start, prepare:

  • A VPS provider (e.g., DigitalOcean, Vultr, or Hetzner)
  • A domain name
  • SSH client (Terminal / PowerShell / PuTTY)
  • Basic knowledge of your app stack (PHP, Node.js, Laravel etc.)

🔌 Step 1: Create & Configure Your VPS

  1. Choose a Linux distro (Ubuntu 24.04 recommended)
  2. Create a new server with at least 1GB RAM
  3. Add a SSH Key (so you don’t use a password)
  4. Select a region closest to your users
  5. Launch the instance Once launched, note down your public IP address.

💻 Step 2: Connect via SSH

Open your terminal and run:

ssh root@your_server_ip
Enter fullscreen mode Exit fullscreen mode

If you used a custom user later, replace root with that username.

🛡️ Step 3: Secure the Server
Update packages:

sudo apt update && sudo apt upgrade -y
Enter fullscreen mode Exit fullscreen mode

Create a new user

adduser devuser
usermod -aG sudo devuser
Enter fullscreen mode Exit fullscreen mode

Enable firewall

ufw allow OpenSSH
ufw enable
Enter fullscreen mode Exit fullscreen mode

✅ This blocks everything except SSH.

🌐 Step 4: DNS Setup

Go to your domain provider and add:

Type: A

Host: @

Value: your_server_ip

This points your domain to the VPS. Once propagated, your domain will resolve correctly.

🛠️ Step 5: Install Web Server
For Nginx:

sudo apt install nginx
sudo ufw allow 'Nginx Full'
Enter fullscreen mode Exit fullscreen mode

Check status:

systemctl status nginx
Nginx should now serve a default "Welcome" page.

📦 Step 6: Deploy Your App

Depending on your stack:

PHP / Laravel

Copy code to /var/www/yourapp

Set permissions:

sudo chown -R www-data:www-data /var/www/yourapp
Node.js
Enter fullscreen mode Exit fullscreen mode

Clone repo

Install dependencies:

npm install
pm2 start server.js
Enter fullscreen mode Exit fullscreen mode

Both stacks are easy to manage and scalable.

🔒 Step 7: HTTPS with Let’s Encrypt

Install certbot:

sudo apt install certbot python3-certbot-nginx
Enter fullscreen mode Exit fullscreen mode

Run:

sudo certbot --nginx
Enter fullscreen mode Exit fullscreen mode

Follow prompts — this configures SSL automatically.

📌 Step 8: Testing & Monitoring

✔ Visit https://yourdomain.com
✔ Test every route
✔ Check logs:

sudo tail -f /var/log/nginx/error.log
Enter fullscreen mode Exit fullscreen mode

This ensures everything is working after deployment.

🧠 Finishing Tips

  • Always backup your database
  • Setup automatic updates
  • Learn basics of firewall & SSH hardening
  • Monitor uptime with tools like UptimeRobot

Real deployment experience beats tutorials, by practicing these steps you’ll master production servers.

Top comments (0)