Prerequisites
Before starting, ensure you have:
Server Requirements
- • RamNode VPS (Ubuntu 22.04+)
- • Root/sudo access
- • SSH access
- • 1GB+ RAM recommended
Project Requirements
- • Lovable-generated React app
- • Git repository access
- • Basic command line knowledge
- • Domain name (optional)
Initial VPS Setup
Connect to your RamNode VPS and prepare the system:
ssh root@your-server-ipapt update && apt upgrade -yadduser deploy
usermod -aG sudo deploy
su - deploy💡 Security: Using a non-root user for deployment is a security best practice.
Install Required Software
Install Node.js, Nginx, and PM2 process manager:
Install Node.js and npm:
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejsnode --version
npm --versionInstall Nginx:
sudo apt install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginxInstall PM2 Process Manager:
sudo npm install -g pm2✅ All required software is now installed and ready for use.
Project Setup and Deployment
Clone your Lovable project and build it for production:
Clone Your Repository:
cd /home/deploy
git clone https://github.com/your-username/your-lovable-project.git
cd your-lovable-projectInstall Dependencies:
npm installBuild for Production:
npm run buildSet Up Application Directory:
sudo mkdir -p /var/www/your-app
sudo cp -r dist/* /var/www/your-app/
sudo chown -R www-data:www-data /var/www/your-app💡 Note: Lovable apps are typically static React applications that compile to HTML, CSS, and JavaScript files.
Nginx Configuration
Configure Nginx to serve your Lovable application:
Create Nginx Site Configuration:
sudo nano /etc/nginx/sites-available/your-appserver {
listen 80;
server_name your-domain.com www.your-domain.com;
root /var/www/your-app;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
# Handle static assets
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;
}Enable the Site:
sudo ln -s /etc/nginx/sites-available/your-app /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx💡 SPA Routing: The try_files directive ensures client-side routing works correctly for React Router.
SSL Certificate Setup
Secure your application with SSL certificates using Let's Encrypt:
Install Certbot:
sudo apt install certbot python3-certbot-nginx -yObtain SSL Certificate:
sudo certbot --nginx -d your-domain.com -d www.your-domain.comTest Auto-Renewal:
sudo certbot renew --dry-run🔒 Success: Your Lovable app is now secured with HTTPS and auto-renewing SSL certificates.
PM2 Process Manager Setup
While Lovable apps are static, you might want to run additional services:
Create PM2 Ecosystem File (Optional):
module.exports = {
apps: [{
name: 'your-lovable-app-api',
script: 'server.js', // If you have a separate API server
cwd: '/home/deploy/your-lovable-project',
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: '1G',
env: {
NODE_ENV: 'production',
PORT: 3001
}
}]
};Setup PM2 Startup:
pm2 startup
pm2 save💡 Note: Most Lovable apps are pure frontend applications and don't require PM2, but it's useful for any backend services.
Automated Deployment Setup
Create a deployment script for easy updates:
Create Deployment Script:
nano /home/deploy/deploy.sh#!/bin/bash
# Navigate to project directory
cd /home/deploy/your-lovable-project
# Pull latest changes
git pull origin main
# Install/update dependencies
npm install
# Build the application
npm run build
# Copy build files to web directory
sudo cp -r dist/* /var/www/your-app/
# Set proper permissions
sudo chown -R www-data:www-data /var/www/your-app
# Reload Nginx
sudo systemctl reload nginx
echo "Deployment completed successfully!"Make Script Executable:
chmod +x /home/deploy/deploy.shRun Deployment:
./deploy.sh🚀 Automation: You can now deploy updates with a single command or integrate with CI/CD pipelines.
Domain Configuration
Configure your domain to point to your RamNode VPS:
DNS Configuration:
- • A Record: Point your domain to your VPS IP address
- • CNAME Record: Point www subdomain to your main domain
- • TTL: Set to 300 seconds for faster propagation during setup
Verify DNS Propagation:
nslookup your-domain.com
dig your-domain.com💡 Tip: DNS propagation can take up to 48 hours, but usually completes within a few hours.
Monitoring and Maintenance
Set up monitoring and maintenance routines:
Server Monitoring:
- • Monitor disk space usage
- • Check server resource usage
- • Monitor Nginx access logs
- • Set up log rotation
Application Monitoring:
- • Monitor application performance
- • Set up uptime monitoring
- • Track user analytics
- • Monitor SSL certificate expiry
Useful Monitoring Commands:
# Check disk usage
df -h
# Monitor system resources
htop
# Check Nginx status and logs
sudo systemctl status nginx
sudo tail -f /var/log/nginx/access.log
# Check SSL certificate expiry
sudo certbot certificatesTroubleshooting Common Issues
🎉 Your Lovable App is Live!
Congratulations! Your Lovable-generated React application is now successfully deployed on your RamNode VPS. You have complete control over your hosting environment with excellent performance, security, and scalability.
