Installation Guide
This guide covers detailed installation instructions for Directus, including Docker deployment, npm/pnpm installation, and production environment configuration.node -vInstallation Methods
Choose the installation method that best fits your needs:- Docker (Recommended)
- npm
- pnpm
- From Source
Docker Installation
Docker is the recommended method for production deployments. Directus provides official Docker images.Quick Start with Docker
Pull the Directus Image
Run with SQLite (Development)
Production Docker Compose Setup
For production, use Docker Compose with PostgreSQL:Create docker-compose.yml
docker-compose.yml file:Generate Secure Keys
KEY and SECRET:docker-compose.yml with these values.Start the Services
- Start PostgreSQL database
- Start Redis cache
- Start Directus
- Bootstrap the database on first run
Verify Installation
http://localhost:8055Dockerfile Reference
The official Directus Dockerfile uses a multi-stage build:npm/pnpm Installation
Install via npm
Install Directus Globally
Create a New Project
Install Database Driver
Configure Environment
.env file created during init. See Environment Configuration below.Bootstrap and Start
Install via pnpm
Install Directus Globally
Create and Setup Project
Install Database Driver
Bootstrap and Start
Install from Source
For development or if you want to customize Directus:Clone the Repository
Install Dependencies
Build All Packages
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:Database
Database
- 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"
Security
Security
- Generate strong
KEY(32 characters) andSECRET - Set
REFRESH_TOKEN_COOKIE_SECURE="true" - Set
SESSION_COOKIE_SECURE="true" - Configure
PUBLIC_URLto your domain - Enable and configure CORS appropriately
- Set up rate limiting with Redis
- Review and configure
CORS_ORIGIN
Performance
Performance
- Enable Redis caching:
CACHE_ENABLED="true" - Configure rate limiting with Redis store
- Set appropriate cache TTL values
- Use CDN for assets
- Configure
MAX_PAYLOAD_SIZEbased on needs
Storage
Storage
- Configure cloud storage (S3, Azure, GCS)
- Set up CDN for file delivery
- Configure appropriate file upload limits
- Enable server-side encryption if required
Email
- Configure email transport (SMTP, SES, etc.)
- Set
EMAIL_FROMto valid sender address - Test password reset emails
- Configure email rate limiting
Monitoring
Monitoring
- 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
SSL/TLS
SSL/TLS
- 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:Troubleshooting
Database connection errors
Database connection errors
- 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
Port already in use
Port already in use
Error: listen EADDRINUSE: address already in use :::8055Solutions:- Change port:
PORT=3000in.env - Find and kill process using port 8055:
KEY or SECRET not set
KEY or SECRET not set
Error: KEY environment variable is requiredSolutions:- Generate keys:
- Add to
.envfile
File upload errors
File upload errors
- Check
STORAGE_LOCAL_ROOTdirectory exists and is writable - Increase
MAX_PAYLOAD_SIZEif files are large - Verify disk space
- Check file permissions on upload directory
Docker container won't start
Docker container won't start
- 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