Originally published at https://codebuddy.tech/blog/how-to-deploy-15-web-apps-on-one-server-with-pm2.html?utm_source=devto&utm_medium=syndication&utm_campaign=cbs_affiliate&utm_content=hostinger
How to Deploy 15 Web Apps on One Server with PM2
Published 2026-04-19 · codebuddy.tech
How to Deploy 15 Web Apps on One Server with PM2
Running multiple web applications on a single server isn't just possible—it's the norm for efficient development shops. At CodeBuddy.tech, we regularly deploy 15+ apps on individual VPSs using PM2, delivering fast, reliable solutions for our clients while keeping costs down. Here's exactly how we do it.
Why PM2 for Multi-App Deployments
PM2 (Process Manager 2) is a production-ready process manager for Node.js applications. Unlike basic node commands, PM2 keeps your apps running, restarts them on crashes, and provides monitoring capabilities essential for production environments.
The key advantages for multi-app deployments:
Zero-downtime deployments
Built-in load balancer
Memory and CPU monitoring
Automatic restarts on crashes
Log management for all applications
Server Requirements and Setup
For our typical 15-app setup, we use Hostinger VPS instances (affiliate link) with at least 8GB RAM and 4 CPU cores. The reliability and pricing make them perfect for our fast-delivery model.
Storage is crucial when managing multiple applications. We often recommend the Seagate IronWolf Pro 16TB (US affiliate link) or Canadian version (CA affiliate link) for clients requiring extensive local storage and backup capabilities.
Disclosure: We earn commissions from qualifying purchases through these affiliate links, which helps support our development work.
Initial Server Configuration
Start with a fresh Ubuntu 22.04 instance. Update the system and install essential packages:
sudo apt update && sudo apt upgrade -y
sudo apt install nginx nodejs npm git -y
sudo npm install -g pm2
Configure nginx as a reverse proxy. Create a main configuration that will route different domains or subdomains to different ports:
sudo nano /etc/nginx/sites-available/multi-app
PM2 Configuration Strategy
The secret to managing 15 apps efficiently is using PM2's ecosystem file. Create a master configuration:
// ecosystem.config.js
module.exports = {
apps: [
{
name: 'app-1',
script: './app1/server.js',
instances: 1,
env: {
PORT: 3001,
NODE_ENV: 'production'
}
},
{
name: 'app-2',
script: './app2/server.js',
instances: 1,
env: {
PORT: 3002,
NODE_ENV: 'production'
}
},
// ... repeat for all 15 apps
]
}
This approach lets you manage all applications with single commands while maintaining individual control over each app's environment and resources.
Port Management and Nginx Routing
Assign sequential ports starting from 3001. This systematic approach prevents conflicts and makes troubleshooting straightforward. Configure nginx to route based on server names:
server {
listen 80;
server_name app1.yourdomain.com;
location / {
proxy_pass http://localhost:3001;
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;
}
}
Repeat this server block for each application, adjusting the server_name and proxy_pass port accordingly.
Resource Monitoring and Limits
With 15 applications running simultaneously, resource management becomes critical. PM2 provides built-in monitoring:
pm2 monit
Set memory limits for each application to prevent any single app from consuming excessive resources:
{
name: 'app-1',
script: './app1/server.js',
max_memory_restart: '200M',
instances: 1
}
This configuration automatically restarts applications that exceed memory thresholds, maintaining overall server stability.
Deployment Workflow
Our deployment process at CodeBuddy.tech prioritizes speed and reliability. We use this workflow for client projects:
Deploy all applications: pm2 start ecosystem.config.js
Save PM2 configuration: pm2 save
Setup startup script: pm2 startup
Test all endpoints through nginx
Configure SSL certificates with Let's Encrypt
For updates, PM2's reload feature ensures zero downtime:
pm2 reload app-name
Log Management
Managing logs for 15 applications requires organization. PM2 centralizes logging, but configure log rotation to prevent disk space issues:
pm2 install pm2-logrotate
pm2 set pm2-logrotate:max_size 10M
pm2 set pm2-logrotate:compress true
Access logs for specific applications:
pm2 logs app-name --lines 50
Security Considerations
Running multiple applications increases the attack surface. Implement these security measures:
Configure firewall to only allow necessary ports
Use SSL certificates for all applications
Implement rate limiting in nginx
Regular security updates
Monitor unusual resource usage
Performance Optimization
To maintain optimal performance across all applications:
Enable gzip compression in nginx
Configure appropriate caching headers
Use PM2 cluster mode for CPU-intensive apps
Monitor and optimize database connections
Implement health checks for each application
Scaling and Maintenance
As applications grow, monitor resource usage and be prepared to scale vertically or horizontally. PM2's cluster mode can help distribute load for individual applications:
{
name: 'high-traffic-app',
script: './app/server.js',
instances: 'max',
exec_mode: 'cluster'
}
Regular maintenance includes updating dependencies, monitoring disk space, and reviewing application logs for errors or performance issues.
Get Your Multi-App Deployment Built
Managing 15 web applications on a single server with PM2 is entirely achievable with proper configuration and monitoring. This approach powers our rapid development model at CodeBuddy.tech, where we build fast, escrow-protected solutions right from our Vancouver office—often while mobile.
Top comments (0)