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!

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where youā€™ll build it, break it, debug it, and fix it. Youā€™ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good olā€™ AI to find and fix issues fast.

RSVP here ā†’

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