A streamlined guide for deploying AgentifUI on your own server with all required dependencies.
This guide will help you deploy AgentifUI on a VPS or dedicated server.
What we'll install:
- Node.js (via NVM)
- pnpm package manager
- PM2 process manager
- Supabase CLI
- Docker & Docker Compose
- Dify (self-hosted AI platform)
- AgentifUI application
Update your system packages:
# Ubuntu/Debian
sudo apt-get update && sudo apt-get upgrade -y
# CentOS/RHEL
sudo yum update -yInstall NVM (Node Version Manager) for flexible Node.js management:
# Install NVM
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
# Reload shell configuration
source ~/.bashrc # or ~/.zshrc for zsh users
# Install and use Node.js LTS
nvm install --lts
nvm use --lts
# Verify installation
node --version # Should show v22.x.x or later# Install pnpm globally
npm install -g pnpm
# Verify installation
pnpm --version # Should show 10.x.x or later# Install PM2 globally
npm install -g pm2
# Verify installation
pm2 --version
Choose your installation method:
For macOS:
brew install supabase/tap/supabaseFor Linux:
curl -sL https://github.com/supabase/cli/releases/latest/download/supabase_linux_amd64.tar.gz | tar -xz
sudo mv supabase /usr/local/bin/
# Verify installation
supabase --versionMethod 1: Official Docker Installation (Recommended)
# Update system packages
sudo apt-get update && sudo apt-get upgrade -y
# Install required packages
sudo apt-get install ca-certificates curl gnupg lsb-release -y
# Create directory for apt keyrings
sudo install -m 0755 -d /etc/apt/keyrings
# Add Docker's official GPG key
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release && echo "$ID")/gpg \
| sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
# Add Docker repository to apt sources
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/$(. /etc/os-release && echo "$ID") \
$(lsb_release -cs) stable" \
| sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Update package index and install Docker
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
# Add current user to docker group
sudo usermod -aG docker $USER
# Logout and login again, or run:
newgrp docker
# Verify Docker installation
sudo docker run hello-world
docker --version
docker compose versionMethod 2: Quick Installation Script (Alternative)
# Quick install with convenience script
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
# Add current user to docker group
sudo usermod -aG docker $USER
newgrp docker
# Verify installation
docker --version
docker compose version# Clone Dify repository
git clone https://github.com/langgenius/dify.git
cd dify/docker
# Copy environment template
cp .env.example .env
# Edit the configuration to change the port (optional)
nano .envImportant Port Configuration:
If you want to run Dify on a different port (recommended to avoid conflicts), edit the .env file:
# Change the default port from 80 to 3002
EXPOSE_NGINX_PORT=3002Start Dify services:
# Start Dify with Docker Compose
docker compose up -d
# Check if services are running
docker compose ps
# View logs if needed
docker compose logs -fAccess Dify Setup:
- Open your browser and go to
http://your-server-ip:3002 - Complete the initial setup wizard
- Create your first application
- Note down the API endpoint and key for later configuration
# Navigate to your desired directory (e.g., /opt or /home/user)
cd /opt # or your preferred location
# Clone AgentifUI repository
git clone https://github.com/ifLabX/AgentifUI.git
cd AgentifUI
# Install dependencies
pnpm installOption A: Use Local Supabase (Recommended for self-hosted)
# Navigate to AgentifUI directory (if not already there)
cd AgentifUI
# Start local Supabase instance (project already includes Supabase config)
supabase start
# IMPORTANT: Note down the output values - you'll need them for the next step:
# - API URL (usually http://localhost:54321)
# - anon key
# - service_role key
# Apply database migrations
supabase db push --localOption B: Use Supabase Cloud
- Visit Supabase Dashboard
- Create a new project
- Go to Settings β API
- Copy the Project URL and API keys
- Run:
supabase link --project-ref your-project-id - Run:
supabase db push
Create the production environment file:
# Copy environment template
cp .env.example .env
# Edit environment variables
nano .envEssential environment variables:
# ===========================================
# Supabase Configuration (Required)
# ===========================================
NEXT_PUBLIC_SUPABASE_URL=http://localhost:54321
# For cloud Supabase, use: https://your-project-ref.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-local-anon-key-from-supabase-start
SUPABASE_SERVICE_ROLE_KEY=your-local-service-role-key-from-supabase-start
# Required only for self-hosted Supabase installations
# SUPABASE_JWT_SECRET=your-jwt-secret
# ===========================================
# API Encryption Key (Required)
# ===========================================
API_ENCRYPTION_KEY=your-32-byte-hex-string
# ===========================================
# Application Settings (Required)
# ===========================================
NEXT_PUBLIC_APP_URL=http://your-server-ip:3000
# ===========================================
# Authentication & SSO (Optional)
# ===========================================
NEXT_PUBLIC_SSO_ONLY_MODE=false
# ===========================================
# CORS Settings (Important for production)
# ===========================================
CORS_ALLOWED_ORIGINS=http://your-server-ip:3000,http://your-domain.com
# Optional for development only
# DEV_ALLOWED_ORIGINS=http://localhost:3000,http://127.0.0.1:3000Generate API Encryption Key:
# Generate a secure 32-byte hex key
openssl rand -hex 32Important: Use the actual values from the supabase start output in the previous step for the Supabase keys.
# Deploy with PM2 (this will automatically build the application)
pnpm run deploy
# Check deployment status
pm2 list
pm2 logs
# Save PM2 configuration for auto-restart
pm2 saveNote: The pnpm run deploy command automatically builds the application using build:standalone mode and then starts it with PM2. If you prefer the legacy deployment method, you can use pnpm run deploy:legacy instead.
Verify all services are running:
# Check PM2 processes
pm2 status
# Check Docker containers
docker ps
# Check Supabase status
supabase status
# Test application response
curl -I http://localhost:3000Access your application:
- AgentifUI:
http://your-server-ip:3000 - Dify:
http://your-server-ip:3002 - Supabase Studio:
http://localhost:54323(if using local)
-
Register a user account:
- Visit your AgentifUI URL
- Click "Register" and create an account
-
Promote to admin via Supabase:
# Access Supabase SQL Editor (local: http://localhost:54323) # Run this SQL query:
SELECT public.initialize_admin('your-email@example.com');
-
Verify admin access:
- Log out and log back in
- Visit
/adminroute - You should see the admin dashboard
PM2 Management:
# View status
pm2 status
# View logs
pm2 logs
# Restart application
pm2 restart all
# Stop application
pm2 stop all
# Monitor resources
pm2 monitDify Management:
cd /path/to/dify/docker
# Stop Dify
docker compose down
# Start Dify
docker compose up -d
# View logs
docker compose logs -fSupabase Management:
# Stop local Supabase
supabase stop
# Start local Supabase
supabase start
# Reset database (caution!)
supabase db reset --localPort conflicts:
# Check what's using a port
sudo lsof -i :3000
sudo lsof -i :3002
# Kill process if needed
sudo kill -9 <PID>Service not starting:
# Check logs
pm2 logs
docker compose logs
journalctl -u docker
# Restart services
pm2 restart all
docker compose restart
sudo systemctl restart dockerDatabase connection issues:
# Check Supabase status
supabase status
# Reset and restart
supabase db reset --local
supabase db push --local-
Firewall Configuration:
# Install UFW (Ubuntu) sudo ufw enable sudo ufw allow ssh sudo ufw allow 3000 # AgentifUI sudo ufw allow 3002 # Dify (if exposing publicly)
-
SSL/HTTPS Setup:
- Use a reverse proxy (nginx/apache) with Let's Encrypt
- Configure proper domain names
- Redirect HTTP to HTTPS
-
Regular Updates:
# Update system packages sudo apt update && sudo apt upgrade # Update Node.js nvm install --lts nvm use --lts # Update application cd /opt/AgentifUI git pull pnpm install pnpm run build pm2 restart all
System Resources:
# Monitor CPU/Memory
htop
# Check disk space
df -h
# Monitor network
iftopApplication Health:
# PM2 monitoring
pm2 monitYour AgentifUI deployment is now complete! The application should be accessible at your server's IP address on port 3000.
Next Steps:
- Configure a domain name and SSL certificate for production use
- Set up regular backups for your database
- Configure monitoring and alerting
- Create additional admin users as needed
Support:
- Documentation: GitHub Repository
- Issues: GitHub Issues
- Community: Join project discussions
π Your AgentifUI server is ready to use!