Full Deployment Steps for Lovable.dev App on Ubuntu 24.04
✅ 1. Install Required Packages
sudo apt update && sudo apt upgrade -y
sudo apt install git curl nginx ufw unzip
Install Node.js and npm (assumes the frontend is React):
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
Optional: Install pnpm (Lovable may use it):
npm install -g pnpm
✅ 2. Clone Your Project from GitHub
cd /var/www
sudo git clone https://github.com/YOUR_USERNAME/YOUR_PROJECT.git
sudo chown -R $USER:$USER YOUR_PROJECT
cd YOUR_PROJECT
✅ 3. Build the Frontend
If it’s a React or Next.js app (Lovable uses Vite or Next.js commonly):
npm install # or npm install
pnpm build # or npm run build
This should generate a dist or .next directory with production assets.
✅ 4. Install a Backend (Optional)
If your app uses Supabase, your backend is hosted. If it has a custom backend (e.g. Express), you’ll need to install:
# If using Express or another Node backend
pnpm start # or npm start
Or, if it’s a full-stack project with a backend in a separate folder (/api, for example), set up environment variables (.env) and run it accordingly.
✅ 5. Configure NGINX for Reverse Proxy
Create a new config:
sudo nano /etc/nginx/sites-available/yourapp
Paste this basic config:
server {
listen 80;
server_name yourdomain.com;
root /var/www/YOUR_PROJECT/dist; # or .next/out if Next.js static export
index index.html;
location / {
try_files $uri /index.html;
}
# Proxy to backend if applicable
location /api/ {
proxy_pass http://localhost:3001; # or wherever your backend runs
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 and reload:
sudo ln -s /etc/nginx/sites-available/yourapp /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
✅ 6. Set Up a Process Manager (Optional for Backend)
Use pm2 to keep backend running:
npm install -g pm2
pm2 start server.js # or index.js, main.js
pm2 save
pm2 startup
✅ 7. (Optional) Enable HTTPS with Certbot
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d yourdomain.com
✅ 8. Configure Firewall
sudo ufw allow 'Nginx Full'
sudo ufw enable
🎉 You’re Done!
Visit http://yourdomain.com or http://your_server_ip to view your app.
