Skip to content

Instantly share code, notes, and snippets.

@nadeemmaahmud
Forked from shaishab316/deploy-cheatsheet.md
Created December 15, 2025 00:05
Show Gist options
  • Select an option

  • Save nadeemmaahmud/af0f6f1b63f252b152b7d76a146d39a8 to your computer and use it in GitHub Desktop.

Select an option

Save nadeemmaahmud/af0f6f1b63f252b152b7d76a146d39a8 to your computer and use it in GitHub Desktop.
A step-by-step guide to deploy React frontend, Node.js backend, and Dashboard on a fresh VPS using NGINX reverse proxy, PM2 process manager, and free SSL via Certbot. Perfect for production-ready hosting with subdomains (api & dashboard) and automatic service startup.

🌐 Easy Hosting Guide on Vps (MEAN stack)

One click deploy using

vpsify


βœ… Step 0: Set Up Domain First

  1. Open your domain provider’s dashboard (e.g., Namecheap, GoDaddy, Cloudflare, Hostinger, Porkbun, etc.)
  2. Go to Domain List β†’ DNS Zone
  3. Now observe: πŸ” If there are old A records named @, api or dashboard πŸ‘‰ Delete them first.

⚠️ DNS will NOT work if there are multiple A records with the same name.

  1. Now add three new A records as shown below (use your VPS IP):
image

βœ… Step 1: Log in to VPS Using VS Code

  1. Open VS Code
  2. Go to Extensions (Ctrl + Shift + X)
  3. Search Remote - SSH β†’ Install
image
  1. Press Ctrl + Shift + P β†’ search:
image
  1. When asked, enter:
image
  1. Press Enter and you will be connected πŸŽ‰

βœ… Step 2: Install Necessary Software in VPS

Copy and run:

apt update && apt upgrade -y
apt install -y nginx curl unzip git certbot python3-certbot-nginx

curl -fsSL https://deb.nodesource.com/setup_24.x | bash -
apt install -y nodejs
npm i -g pm2

systemctl enable nginx
systemctl start nginx

πŸ‘‰ This installs all required packages & starts NGINX.


βœ… Step 3: Upload Your Projects (Drag & Drop)

In VS Code, open /var/www/ folder.

Drag your project folders here:

Project Upload To
Frontend (React) /var/www/frontend
Backend (Node.js) /var/www/backend
Dashboard (React) /var/www/dashboard

Then go inside each folder and run:

npm install

βœ… Step 4: Run Projects Using PM2

cd /var/www/frontend
pm2 start npm --name frontend -- start

cd /var/www/backend
pm2 start npm --name backend -- start

cd /var/www/dashboard
pm2 start npm --name dashboard -- start

Save and enable autostart:

pm2 save
pm2 startup

βœ… Step 5: Configure NGINX

πŸ“ Go to /etc/nginx/sites-available/


⚠️ Important

πŸ”₯ Delete the file named default. πŸ›‘ Do not delete any other file.

Why? If it stays, your subdomains will not work and you will see the default NGINX page.


πŸ›  Create 3 files:

  • root
  • api
  • dashboard

Put the following configuration (change subdomain + port):

server {
    listen 80;
    server_name (subdomain.)yourdomain.com;

    location / {
        proxy_pass http://localhost:(port);
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

Enable them:

sudo ln -s /etc/nginx/sites-available/root /etc/nginx/sites-enabled/
sudo ln -s /etc/nginx/sites-available/api /etc/nginx/sites-enabled/
sudo ln -s /etc/nginx/sites-available/dashboard /etc/nginx/sites-enabled/
image

πŸ” Reload NGINX

nginx -t
systemctl reload nginx

βœ… Step 6: Install SSL (HTTPS Free Certificate)

certbot --nginx -d yourdomain.com -d www.yourdomain.com -d api.yourdomain.com -d dashboard.yourdomain.com

Choose Redirect HTTP to HTTPS when asked.


πŸŽ‰ Done!

URL Shows
https://yourdomain.com, https://www.yourdomain.com Main App
https://api.yourdomain.com Backend API
https://dashboard.yourdomain.com Dashboard

βš™οΈ Useful Commands

🟒 PM2

pm2 ls
pm2 restart name/all
pm2 stop name
pm2 delete name
pm2 save
pm2 startup
pm2 logs (name)

🌐 NGINX

nginx -t
systemctl reload nginx

πŸ” SSL Renew Test

certbot renew --dry-run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment