Here’s a step-by-step guide on how to deploy a Node.js app on a Germany VPS:
1. Choose a Germany VPS Provider
Select a reliable VPS provider with German datacenters (like 99RDP, Hetzner, or Contabo).
Make sure the plan has enough CPU, RAM, and bandwidth for your Node.js application.
2. Connect to Your VPS
After purchasing, you’ll receive an IP, username, and password.
Use SSH to connect:
ssh root@your-vps-ip
3. Update and Install Essentials
Before installing Node.js, update your VPS:
sudo apt update && sudo apt upgrade -y
sudo apt install curl git build-essential -y
4. Install Node.js and npm
You can install Node.js using NodeSource (recommended):
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install -y nodejs
Check versions:
node -v
npm -v
5. Upload Your Node.js App
Clone from GitHub or upload files via SCP/FTP:
git clone https://github.com/your-username/your-nodejs-app.git
cd your-nodejs-app
npm install
6. Run the App (Test Mode)
Start your app to confirm it works:
node app.js
If you see it running on a port (like http://localhost:3000), it’s working.
7. Use PM2 for Process Management
Instead of running it manually, install PM2:
sudo npm install -g pm2
Start app with PM2:
pm2 start app.js --name "myapp"
Make it auto-start on reboot:
pm2 startup systemd
pm2 save
8. Reverse Proxy with Nginx
Since Node.js apps usually run on a port (e.g., 3000), set up Nginx as a reverse proxy to serve it on port 80/443.
Install Nginx:
sudo apt install nginx -y
Configure a site:
sudo nano /etc/nginx/sites-available/myapp
Paste this:
server {
listen 80;
server_name yourdomain.com;
location / {
proxy_pass http://localhost:3000;
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 config:
sudo ln -s /etc/nginx/sites-available/myapp /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
9. Secure with SSL (HTTPS)
Use Let’s Encrypt for free SSL:
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d yourdomain.com
SSL will be auto-renewed.
10. Final Testing
-
Visit
http://yourdomain.com(or VPS IP if no domain). -
Your Node.js app should load through Nginx.
-
PM2 keeps it alive, and Nginx handles traffic + SSL.
✅ Now your Node.js app is live on a Germany VPS.

No comments:
Post a Comment