This guide provides step-by-step instructions for deploying the LeadsFire Voice AI System to a Vultr VPS.
- Vultr VPS (1 CPU, 1GB RAM, 25GB NVMe)
- Domain name (leadsfire.com) pointed to server IP (155.138.252.182)
- GitHub repository access
- All API keys and credentials from .env file
- SSH into your server:
ssh chris@155.138.252.182
- Update system and install required packages:
sudo apt update && sudo apt upgrade -y
sudo apt install -y python3.12 python3.12-venv python3.12-dev build-essential nginx git nodejs npm certbot python3-certbot-nginx ufw
- Install PM2:
sudo npm install -g pm2
- Set up UFW firewall:
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh
sudo ufw allow 'Nginx Full'
sudo ufw enable
- Allow specific IPs for admin access:
sudo ufw allow from 162.157.115.237 to any port 80,443
sudo ufw allow from 144.202.70.89 to any port 80,443
- Install SSL certificate:
sudo certbot --nginx -d leadsfire.com -d www.leadsfire.com
- Create application directory:
sudo mkdir -p /var/www/leadsfire
sudo chown chris:chris /var/www/leadsfire
- Clone repository:
cd /var/www/leadsfire
git clone https://github.com/clicksmartmedia/leadsfire.com.git .
- Set up Python virtual environment:
python3.12 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
- Create and configure .env file:
cp .env.example .env
nano .env
# Add your production credentials
- Create Nginx configuration:
sudo nano /etc/nginx/sites-available/leadsfire.com
- Add the following configuration:
server {
listen 80;
server_name leadsfire.com www.leadsfire.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name leadsfire.com www.leadsfire.com;
ssl_certificate /etc/letsencrypt/live/leadsfire.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/leadsfire.com/privkey.pem;
access_log /var/log/nginx/leadsfire.access.log;
error_log /var/log/nginx/leadsfire.error.log;
location / {
proxy_pass http://127.0.0.1:5001;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Allow Twilio webhooks
location /voice/ {
proxy_pass http://127.0.0.1:5001;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
allow all;
}
# Restrict admin endpoints
location /logs {
proxy_pass http://127.0.0.1:5001;
proxy_set_header Host $host;
allow 162.157.115.237;
allow 144.202.70.89;
deny all;
}
}
- Enable the site:
sudo ln -s /etc/nginx/sites-available/leadsfire.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
- Create PM2 ecosystem file:
cd /var/www/leadsfire
nano ecosystem.config.js
- Add the following configuration:
module.exports = {
apps: [{
name: "leadsfire",
script: "/var/www/leadsfire/venv/bin/python",
args: "app.py",
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: "750M",
env: {
NODE_ENV: "production",
FLASK_ENV: "production"
}
}]
}
- Start the application:
pm2 start ecosystem.config.js
pm2 save
pm2 startup
- Create logrotate configuration:
sudo nano /etc/logrotate.d/leadsfire
- Add the following configuration:
/var/log/nginx/leadsfire.*.log {
daily
rotate 30
compress
delaycompress
notifempty
create 0640 www-data adm
sharedscripts
postrotate
[ -f /var/run/nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`
endscript
}
To update the application:
- Pull latest changes:
cd /var/www/leadsfire
git pull origin main
- Install any new dependencies:
source venv/bin/activate
pip install -r requirements.txt
- Restart the application:
pm2 restart leadsfire
- View application logs:
pm2 logs leadsfire
- Monitor application status:
pm2 monit
- View Nginx access logs:
sudo tail -f /var/log/nginx/leadsfire.access.log
MongoDB Atlas handles database backups. For application files:
sudo tar -czf /backup/leadsfire-$(date +%Y%m%d).tar.gz /var/www/leadsfire
- Check application status:
pm2 status
- View error logs:
pm2 logs leadsfire --err
- Test Nginx configuration:
sudo nginx -t
- Check SSL certificate:
sudo certbot certificates