DEV Community

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

Posted on

1 1

🚀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!

Image of Datadog

The Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Google’s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

Learn More

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay