Deployment (VPS)
This guide explains how to deploy the Pixel-AI backend on a VPS (Virtual Private Server). You will configure the server, install required software, secure the database, and run Pixel-AI in a production-ready environment.
VPS deployment is recommended because it provides Full server control, Better performance tuning, Secure API handling, SSL support, Background processing (AI jobs, queue workers), Scalability for SaaS growth.
1. System Setup
After connecting to your VPS via SSH:
sudo apt update && sudo apt upgrade -y
sudo apt install curl wget git unzip build-essential -y
These utilities are required for installing Node.js, MongoDB, and managing your backend.
2. Install Node.js Runtime
Pixel-AI backend runs on Node.js. Install latest LTS (recommended for production):
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejs
Verify installation:
node -v
npm -v
You should see Node 22.x (or latest LTS).
3. Install & Configure MongoDB (Database)
Pixel-AI uses MongoDB to store: Users, Human Agent, AI generations, API usage, AI Chatbot, Prompt history.
Step 1 — Import MongoDB GPG Key (Version 8.0)
curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | \
sudo gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg --dearmor
Step 2 — Add Repository (Ubuntu 24.04 / 22.04)
# For Ubuntu 24.04 (noble):
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse" | \
sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list
# Note: For Ubuntu 22.04 use "jammy" instead of "noble".
Step 3 — Install MongoDB
sudo apt update
sudo apt install -y mongodb-org
Step 4 — Start & Enable Service
sudo systemctl start mongod
sudo systemctl enable mongod
Step 5 — Verify Installation
sudo systemctl status mongod
mongod --version
mongosh --version
4. Deploy Pixel-AI Backend Code
Clone your backend repository:
git clone https://github.com/yourusername/pixel-ai-backend.git
cd pixel-ai-backend
npm install --production
5. Configure Environment Variables
Create .env file:
nano .env
Example Production Configuration:
NODE_ENV=
PORT=
MONGODB_URI=
JWT_SECRET=
APP_DEMO_MODE=
BASE_URL=
PUBLIC_URL=
FRONTEND_URL=
# Admin Credentials
ADMIN_EMAIL=
ADMIN_PASSWORD=
ADMIN_NAME=
REDIS_URL=
GEMINI_API_KEY=
INSTAGRAM_VERIFY_TOKEN=
MESSENGER_VERIFY_TOKEN=
ENCRYPTION_KEY=
ALLOWED_ORIGINS=
6. Process Management (PM2)
Install PM2 and start backend:
sudo npm install -g pm2
pm2 start server.js --name pixelai-backend
pm2 save
pm2 startup
Check logs:
pm2 logs pixelai-backend
PM2 ensures: Auto restart on crash, Background execution, Memory monitoring, Log management.
7. Reverse Proxy Setup (Nginx)
Pixel-AI runs internally on port 5000. Install Nginx and create config:
sudo apt install nginx -y
sudo nano /etc/nginx/sites-available/pixelai
Add configuration:
server {
listen 80;
server_name your-domain.com;
location / {
proxy_pass http://localhost:5000;
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 configuration:
sudo ln -s /etc/nginx/sites-available/pixelai /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
8. Enable SSL (HTTPS)
Install Certbot and generate SSL:
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d your-domain.com
Set up auto renewal:
sudo crontab -e
# Add the following line:
0 12 * * * /usr/bin/certbot renew --quiet
Now Pixel-AI runs securely via HTTPS.
9. Testing & Verification
Test health endpoint and common features:
https://your-domain.com/api/health
Check: Authentication, AI generation endpoints, Payment webhooks, Email campaigns, Ai chatbot creation.
Logs: pm2 logs pixelai-backend
10. Maintenance & Updates
To update backend:
cd pixel-ai-backend
git pull origin main
npm install --production
pm2 restart pixelai-backend
Regularly monitor: CPU & RAM, MongoDB memory usage, Disk space, Payment webhook logs, SSL renewal status.
What's Next?
Let's get started — your journey with Pixel AI begins here!