Skip to main content

Installation Guide

This guide covers detailed installation instructions for Directus, including Docker deployment, npm/pnpm installation, and production environment configuration.
Requirements: Directus requires Node.js 22 or higher. Check your version with node -v

Installation Methods

Choose the installation method that best fits your needs:

Docker Installation

Docker is the recommended method for production deployments. Directus provides official Docker images.

Quick Start with Docker

1

Pull the Directus Image

2

Run with SQLite (Development)

For quick testing with SQLite:
SQLite is great for development but not recommended for production. Use PostgreSQL or MySQL for production deployments.

Production Docker Compose Setup

For production, use Docker Compose with PostgreSQL:
1

Create docker-compose.yml

Create a docker-compose.yml file:
Security: Replace KEY, SECRET, and all passwords with strong, random values before deploying to production!
2

Generate Secure Keys

Generate secure random values for KEY and SECRET:
Update your docker-compose.yml with these values.
3

Start the Services

This will:
  • Start PostgreSQL database
  • Start Redis cache
  • Start Directus
  • Bootstrap the database on first run
4

Verify Installation

Check that all services are running:
Access Directus at http://localhost:8055

Dockerfile Reference

The official Directus Dockerfile uses a multi-stage build:

npm/pnpm Installation

Install via npm

1

Install Directus Globally

2

Create a New Project

3

Install Database Driver

Install the appropriate database driver:
4

Configure Environment

Edit the .env file created during init. See Environment Configuration below.
5

Bootstrap and Start

Install via pnpm

1

Install Directus Globally

2

Create and Setup Project

3

Install Database Driver

4

Bootstrap and Start

Install from Source

For development or if you want to customize Directus:
1

Clone the Repository

2

Install Dependencies

Directus uses pnpm for package management:
3

Build All Packages

4

Run Development Server

Environment Configuration

Directus is configured via environment variables. Here are the essential configurations:

Core Configuration

Caching with Redis

Storage Configuration

Rate Limiting

Authentication & Security

Email Configuration

Production Deployment

Using PM2 for Process Management

Directus includes PM2 configuration for production deployments:

Nginx Reverse Proxy

Example Nginx configuration:

Production Checklist

Before deploying to production:
  • Use PostgreSQL or MySQL (not SQLite)
  • Set up automated backups
  • Configure connection pooling
  • Enable SSL for database connections
  • Exclude system tables: DB_EXCLUDE_TABLES="spatial_ref_sys,sysdiagrams"
  • Generate strong KEY (32 characters) and SECRET
  • Set REFRESH_TOKEN_COOKIE_SECURE="true"
  • Set SESSION_COOKIE_SECURE="true"
  • Configure PUBLIC_URL to your domain
  • Enable and configure CORS appropriately
  • Set up rate limiting with Redis
  • Review and configure CORS_ORIGIN
  • Enable Redis caching: CACHE_ENABLED="true"
  • Configure rate limiting with Redis store
  • Set appropriate cache TTL values
  • Use CDN for assets
  • Configure MAX_PAYLOAD_SIZE based on needs
  • Configure cloud storage (S3, Azure, GCS)
  • Set up CDN for file delivery
  • Configure appropriate file upload limits
  • Enable server-side encryption if required
  • Configure email transport (SMTP, SES, etc.)
  • Set EMAIL_FROM to valid sender address
  • Test password reset emails
  • Configure email rate limiting
  • Enable logging: Configure Pino log levels
  • Set up health check endpoint: /server/ping
  • Monitor with PM2 or Docker health checks
  • Set up error tracking (Sentry, etc.)
  • Configure metrics export if needed
  • Configure SSL certificates
  • Use reverse proxy (Nginx, Caddy, etc.)
  • Force HTTPS redirects
  • Enable HSTS headers

Database Migration

When updating Directus versions, migrations may be required:
Always backup your database before running migrations!

Troubleshooting

Symptoms: Error connecting to databaseSolutions:
  • Verify database is running
  • Check DB_HOST, DB_PORT, DB_DATABASE, DB_USER, DB_PASSWORD
  • Ensure database driver is installed (pg, mysql2, etc.)
  • Check network connectivity
  • For PostgreSQL, try: DB_SSL="false" if SSL is not configured
Symptoms: Error: listen EADDRINUSE: address already in use :::8055Solutions:
  • Change port: PORT=3000 in .env
  • Find and kill process using port 8055:
Symptoms: Error: KEY environment variable is requiredSolutions:
  • Generate keys:
  • Add to .env file
Symptoms: Files fail to upload or saveSolutions:
  • Check STORAGE_LOCAL_ROOT directory exists and is writable
  • Increase MAX_PAYLOAD_SIZE if files are large
  • Verify disk space
  • Check file permissions on upload directory
Symptoms: Container exits immediatelySolutions:
  • Check logs: docker logs directus
  • Verify all required environment variables are set
  • Ensure database is ready before Directus starts (use depends_on)
  • Check volume mounts are correct

Next Steps

Configure Data Model

Set up your collections, fields, and relationships

Authentication Setup

Configure OAuth, LDAP, SAML, or other auth providers

API Documentation

Learn about REST and GraphQL endpoints

Extensions

Extend Directus with custom interfaces and endpoints

Webhooks & Flows

Automate workflows and integrate with external services

User Management

Set up roles, permissions, and user accounts

Additional Resources