
This guide details the steps required to deploy Directus on Ubuntu VPS server. Our guide walks through deploying Directus on a fresh Ubuntu VPS with PostgreSQL, PM2, and Nginx.
What is Directus?
Directus is an open-source headless CMS and data platform that sits on top of a SQL database (like PostgreSQL or MySQL) and instantly turns it into a real-time API + admin app.
Core Concept
Instead of creating its own database structure, Directus:
- Connects directly to your existing database
- Adds a no-code admin interface
- Automatically generates:
- REST API
- GraphQL API
- Realtime data access
What It Does (In Plain Terms)
- You create tables β Directus turns them into content collections
- You add fields β Directus gives you forms/UI automatically
- Your data β instantly available via API for apps, websites, or services
Key Features
-
Headless CMS
- Manage content without being tied to a frontend
- Use with:
- WordPress frontends
- Next.js / React apps
- Mobile apps
- Static sites
-
Database-First Approach
- Works with:
- PostgreSQL
- MySQL
- SQLite
- No proprietary schema lock-in
-
Auto-Generated APIs
- REST + GraphQL out of the box
- No backend coding required
-
Admin Dashboard
- Clean UI for:
- Content editing
- User roles & permissions
- File uploads
- Workflows
-
Authentication & Permissions
- Fine-grained access control
- JWT-based auth
- Role-based permissions
-
Extensions & Automation
- Webhooks
- Flows (automation builder)
- Custom endpoints
How It Compares
| Tool | Type | Key Difference |
|---|---|---|
| WordPress | Traditional CMS | Tied to frontend |
| Strapi | Headless CMS | Own schema system |
| Directus | Data platform | Uses your existing DB |
Typical Use Cases
- SaaS backends (admin + API)
- Website content management
- Internal dashboards
- Multi-tenant applications
- Data management layer for apps
Why People Use It
- No vendor lock-in
- Works with existing databases
- Fast to deploy
- Developer + non-technical friendly
Simple Architecture
Database (PostgreSQL)
β
Directus
β
REST / GraphQL API
β
Frontend (Website / App)
System Requirements
In order to deploy Directus on Ubuntu VPS, ensure your environment meets the following prerequisite conditions:
- Ubuntu 22.04 LTS / Ubuntu 24.04 LTS VPS
- 2+ GB RAM recommended
- Domain name (optional but recommended)
How to Deploy Directus on Ubuntu VPS (Production-Ready Guide)
To deploy Directus on Ubuntu VPS, follow the steps provided below:
-
Update System
apt update && apt upgrade -y
-
Install Node.js (LTS)
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - apt install -y nodejs
Verify:
node -v npm -v
-
Install PostgreSQL
apt install -y postgresql postgresql-contrib
Switch to postgres user:
sudo -u postgres psql
Create DB + user:
CREATE DATABASE directus; CREATE USER directus_user WITH PASSWORD 'strongpassword'; ALTER ROLE directus_user SET client_encoding TO 'utf8'; ALTER ROLE directus_user SET default_transaction_isolation TO 'read committed'; ALTER ROLE directus_user SET timezone TO 'UTC'; GRANT ALL PRIVILEGES ON DATABASE directus TO directus_user; \q
-
Install Directus
mkdir -p /opt/directus cd /opt/directus npm init -y npm install directus
-
Configure Environment
Create
.envfile:nano /opt/directus/.env
HOST=0.0.0.0 PORT=8055 KEY=your-random-secret-key SECRET=your-random-secret DB_CLIENT=pg DB_HOST=127.0.0.1 DB_PORT=5432 DB_DATABASE=directus DB_USER=directus_user DB_PASSWORD=strongpassword ADMIN_EMAIL=admin@example.com ADMIN_PASSWORD=StrongAdminPassword123
-
Initialize Directus
npx directus bootstrap
-
Test Run
npx directus start
Access:
http://YOUR_SERVER_IP:8055
-
Install PM2 (Process Manager)
npm install -g pm2
Start Directus:
pm2 start "npx directus start" --name directus pm2 save pm2 startup
-
Install Nginx (Reverse Proxy)
apt install -y nginx
Create config:
nano /etc/nginx/sites-available/directus
server { listen 80; server_name yourdomain.com; location / { proxy_pass http://127.0.0.1:8055; 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 site:
ln -s /etc/nginx/sites-available/directus /etc/nginx/sites-enabled/ nginx -t systemctl restart nginx
-
Enable HTTPS (Letβs Encrypt)
Install Certbot:
apt install -y certbot python3-certbot-nginx
Run:
certbot --nginx -d yourdomain.com
-
Firewall Setup
ufw allow OpenSSH ufw allow 'Nginx Full' ufw enable
-
Useful PM2 Commands
pm2 status pm2 logs directus pm2 restart directus pm2 stop directus
-
Optional: Storage (Uploads)
Add to
.env:STORAGE_LOCATIONS=local STORAGE_LOCAL_ROOT=./uploads
Create directory:
mkdir /opt/directus/uploads
-
Production Hardening (Recommended)
- Use strong secrets
- Move
.envpermissions:
chmod 600 /opt/directus/.env
- Enable PostgreSQL remote restrictions
- Set up backups (cron + pg_dump)
- Use Cloudflare or WAF
- Monitor with PM2 + logs
-
Auto Backup Script (Optional)
crontab -e
0 2 * * * pg_dump -U directus_user directus > /opt/backups/directus_$(date +\%F).sql
Done
You now have a production-ready Directus deployment:
- API:
https://yourdomain.com - Admin Panel: same URL
Conclusion
You now know how to deploy Directus on Ubuntu VPS.









