Getting Started with Directus: Self-Host Your CMS in Minutes
Getting Started with Directus: Self-Host Your CMS in Minutes
Directus is one of the fastest ways to set up a full-featured backend for your application. In this quick-start guide, you will have Directus running on your server with Docker in under 5 minutes, complete with a PostgreSQL database and your first content collection.
Prerequisites
- Docker and Docker Compose installed on your server
- A server with at least 1 CPU core and 512MB RAM
- Basic familiarity with the command line
Step 1: Start Directus with Docker
The simplest way to run Directus is with Docker. Create a directory for Directus and run:
mkdir directus && cd directus
Then create a docker-compose.yml file:
services:
directus:
image: directus/directus:latest
restart: unless-stopped
ports:
- 8080:8080
volumes:
- ./data/directus:/data
environment:
DB_CLIENT: sqlite3
SECRET: change-me-to-a-random-secret
ADMIN_EMAIL: admin@example.com
ADMIN_PASSWORD: change-me
Then start it:
docker compose up -d
Open http://localhost:8080 in your browser and log in with the admin credentials you set above. You are now running Directus!
Step 2: Connect to PostgreSQL (Production Setup)
For production use, replace SQLite with PostgreSQL. Create a docker-compose.yml with both services:
services:
postgres:
image: postgres:16-alpine
restart: unless-stopped
volumes:
- ./data/postgres:/var/lib/postgresql/data
environment:
POSTGRES_DB: directus
POSTGRES_USER: directus
POSTGRES_PASSWORD: secure-password
directus:
image: directus/directus:latest
restart: unless-stopped
ports:
- 8080:8080
volumes:
- ./data/uploads:/data/uploads
environment:
DB_CLIENT: pg
DB_HOST: postgres
DB_PORT: 5432
DB_DATABASE: directus
DB_USER: directus
DB_PASSWORD: secure-password
SECRET: your-secure-random-secret
ADMIN_EMAIL: admin@example.com
ADMIN_PASSWORD: your-secure-password
depends_on:
- postgres
Step 3: Create Your First Collection
Once logged into the admin app:
- Click the Settings gear icon in the sidebar
- Go to Data Model and click Create Collection
- Name it
articlesand click Save - Add fields like
title(String),content(WYSIWYG),published_at(DateTime) - Go to the Content module and start adding entries
Your new collection is immediately available via the REST API at /items/articles and via GraphQL at /graphql. No code generation needed — Directus reads your schema and exposes it automatically.
Conclusion
Directus is remarkably simple to set up yet scales to enterprise use cases. With its automatic API generation, granular permissions, and extensible architecture, it is the ideal backend for any self-hosted application. Start with the Docker setup above and explore the admin interface — you will be surprised how much you can accomplish without writing a single line of backend code.