When you get a fresh VPS, the first question is: How do I set it up so I can deploy multiple apps easily?
In this guide, I’ll walk you through a full flow setup that works for Laravel, Node.js, Ruby on Rails, or almost any stack.
We’ll use:
OS: Ubuntu 22.04 LTS
Web Server: Nginx
Process Managers: php-fpm (for PHP), pm2 (for Node.js)
Database: MySQL/MariaDB or PostgreSQL
SSL: Let’s Encrypt (Certbot)
SSH Keys: For secure access
- What You’ll Learn
By the end of this article, you’ll know how to:
✅ Add SSH access to your VPS
✅ Organize multiple apps on the same server
✅ Manage multiple PHP and Node.js versions
✅ Set up domains and subdomains with Nginx
✅ Secure apps with Let’s Encrypt SSL
✅ Deploy apps with a simple Git + build flow
- Requirements
Before we start, make sure you have:
A VPS + a domain
Basic Linux knowledge (cd, nano, systemctl, etc.)
SSH key configured for secure login
Some familiarity with Nginx
At least one project (Laravel, Node.js, or Rails) to deploy
- Directory Structure
We’ll keep all projects under /var/www/ for organization. This makes it easy to manage multiple apps on the same server.
/var/www/
├── laravel-app1/
│ └── public/ # Laravel public folder
├── laravel-app2/
│ └── public/
├── node-app1/
├── node-app2/
- Version Management
Since different projects often require different versions, we’ll use:
php-fpm for multiple PHP versions
NVM for multiple Node.js versions
4.1 PHP
Install multiple PHP versions (7.4, 8.1, 8.2, etc.) with php-fpm.
Each app points to its own PHP socket:
Laravel App1 → PHP 8.1 → /run/php/php8.1-fpm.sock
Laravel App2 → PHP 8.2 → /run/php/php8.2-fpm.sock
Nginx will route each site to the right PHP version.
4.2 Node.js
Use NVM to install the Node.js version your project needs.
Use PM2 to keep apps running in the background.
Nginx will reverse-proxy to the correct port:
node-app1.yourdomain.com → localhost:3001
node-app2.yourdomain.com → localhost:3002
- Domain & Subdomains
Point your DNS records to your VPS IP:
app1.yourdomain.com → VPS IP
app2.yourdomain.com → VPS IP
node1.yourdomain.com → VPS IP
node2.yourdomain.com → VPS IP
On the server, create Nginx configs for each app:
/etc/nginx/sites-available/
├── laravel-app1.conf
├── laravel-app2.conf
├── node-app1.conf
├── node-app2.conf
Then symlink them to sites-enabled/:
sudo ln -s /etc/nginx/sites-available/laravel-app1.conf /etc/nginx/sites-enabled/
- SSL Certificates
Use Let’s Encrypt with Certbot:
Free SSL for each domain/subdomain
Auto-renew every 90 days
Works directly with Nginx
sudo certbot --nginx -d app1.yourdomain.com -d www.app1.yourdomain.com
- Deployment Flow
Here’s the simple deployment workflow you can follow for each project:
Push your code to GitHub.
SSH into your VPS.
Clone or pull the project from GitHub.
Install dependencies:
Laravel → composer install && npm run build
Node.js → npm install && pm2 restart
Run migrations/seeds if needed.
Since Nginx + SSL are already set up, the app goes live instantly. 🚀
✅ Conclusion
With this setup, your VPS becomes a multi-app hosting machine.
PHP apps run side by side with Node.js apps.
Each project has its own domain/subdomain, SSL, and process manager.
Deployment is as easy as git pull && build.
This gives you the flexibility of a PaaS (like Heroku or Vercel) but with the full control of a VPS.
Top comments (0)