DEV Community

Cover image for 🚀Beginner's Guide to Deploying Projects on a VPS Server
Mahmudur Rahman
Mahmudur Rahman

Posted on

🚀Beginner's Guide to Deploying Projects on a VPS Server

Curious about deploying your project on a VPS but don’t know where to start? A Virtual Private Server (VPS) gives you the flexibility and control of a dedicated server without the hefty price tag. Let's dive into how you can deploy your projects with ease!

🌐 What is a VPS?

A VPS is a virtualized server that acts like a dedicated server within a larger physical server. It's perfect for hosting:

✅ Websites & Web Apps

✅ APIs & Backends

✅ Databases & More!


🛠️ Setting Up Your VPS

1. Choosing a VPS Provider

Some popular providers are:

  • DigitalOcean (Beginner-friendly)
  • Linode (Great support)
  • Vultr (Affordable)
  • AWS Lightsail (Simple AWS option)

🔹 Tip: Look for providers offering a free trial or low-cost plans to start.

2. Creating Your VPS

1️⃣ Sign up with your chosen provider.

2️⃣ Create a new server (droplet/instance) with:

  • OS: Ubuntu 22.04 (Recommended)
  • Region close to your target audience
  • Basic CPU & RAM (1GB RAM is enough for small projects)

🔐 Securing Your VPS

Before deploying, secure your VPS:

  1. SSH Access:
    • Use an SSH key for secure login
    • Disable root login for safety
  2. Firewall Setup:

    • Install UFW: sudo apt install ufw
    • Allow essential ports:
     sudo ufw allow OpenSSH  
     sudo ufw allow 80/tcp   # HTTP  
     sudo ufw allow 443/tcp  # HTTPS  
     sudo ufw enable  
    

🚀 Deploying Your Project

1. Installing Required Software

For a Node.js project:

sudo apt update  
sudo apt install nodejs npm  
Enter fullscreen mode Exit fullscreen mode

For a Python project:

sudo apt install python3 python3-pip  
Enter fullscreen mode Exit fullscreen mode

2. Uploading Your Code

  • Use Git:
  sudo apt install git  
  git clone https://github.com/your-repo.git  
Enter fullscreen mode Exit fullscreen mode
  • Or SFTP/FTP for direct file upload.

3. Running Your Project

For Node.js:

npm install  
node app.js  
Enter fullscreen mode Exit fullscreen mode

For Python (e.g., Flask):

pip3 install -r requirements.txt  
python3 app.py  
Enter fullscreen mode Exit fullscreen mode

4. Keeping Your App Running

Install PM2 for Node.js:

sudo npm install -g pm2  
pm2 start app.js  
pm2 startup  
pm2 save  
Enter fullscreen mode Exit fullscreen mode

Or use Gunicorn for Python:

pip3 install gunicorn  
gunicorn app:app --daemon  
Enter fullscreen mode Exit fullscreen mode

5. Setting Up a Domain

  1. Buy a domain from Namecheap, GoDaddy, etc.
  2. Point DNS to your VPS IP.
  3. Install Nginx for reverse proxy:
   sudo apt install nginx  
   sudo nano /etc/nginx/sites-available/default  
Enter fullscreen mode Exit fullscreen mode

Configure Nginx, then restart:

   sudo systemctl restart nginx  
Enter fullscreen mode Exit fullscreen mode

⚡ Bonus Tips

✅ Use Let's Encrypt for free SSL:

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

✅ Monitor with htop and ufw status

✅ Set up automated backups


🎯 Conclusion

Deploying on a VPS might seem daunting at first, but with this guide, you’ll have your projects up and running in no time!

💬 What project are you planning to deploy on your VPS? Share your experience below!

Top comments (0)