Directus VPS: Database-First Headless CMS Iceland
Directus là headless CMS độc đáo theo triết lý database-first - thay vì tạo schema riêng, Directus mount lên SQL database hiện có và tự động tạo REST/GraphQL API với admin panel hoàn chỉnh. Khi chạy Directus trên VPS offshore tại Iceland của AnubizHost, bạn có giao diện quản lý database mạnh mẽ kèm content delivery API và thanh toán hoàn toàn bằng tiền điện tử. Bài viết này hướng dẫn triển khai Directus production với PostgreSQL hoặc MySQL, cấu hình permission chi tiết, flow automation cho workflow phức tạp và tích hợp với frontend Jamstack.
Need this done for your project?
We implement, you ship. Async, documented, done in days.
Lý Do Directus Phù Hợp VPS Offshore
Khác với Strapi tạo schema riêng và lock-in framework, Directus mount thẳng lên database SQL hiện có - PostgreSQL, MySQL, SQLite, MSSQL. Nếu bạn đã có database từ ứng dụng cũ, Directus cho admin panel sẵn sàng dùng trong vài phút mà không cần migration. Khi muốn bỏ Directus, database vẫn nguyên vẹn và dùng được với mọi tool khác.
Triết lý database-first này phù hợp đặc biệt với VPS offshore Iceland của AnubizHost. Bạn có toàn quyền database PostgreSQL với SQL access trực tiếp, Directus chỉ là một layer admin trên đó. Quyền root cho phép tinh chỉnh PostgreSQL theo workload cụ thể - bật query cache, tăng work_mem, tune autovacuum.
VPS Standard 4GB RAM của AnubizHost dư sức chạy Directus với database vài GB. VPS Pro 8GB RAM phục vụ thoải mái 100k record và 50 admin user concurrent. SSD NVMe đảm bảo query response dưới 50ms cho thao tác thông thường.
Đăng ký không KYC, thanh toán Bitcoin hoặc Monero phù hợp cho agency phục vụ nhiều client với CMS riêng, indie developer cần data ownership thực sự, hoặc team backend muốn admin panel mà không phải code từ đầu.
Cài Đặt Directus Qua Docker
Directus distributable nhất qua Docker. Trên VPS từ AnubizHost:
mkdir -p /opt/directus && cd /opt/directus
cat > docker-compose.yml <<EOF
version: "3.8"
services:
database:
image: postgres:16-alpine
restart: always
volumes:
- ./db:/var/lib/postgresql/data
environment:
POSTGRES_USER: directus
POSTGRES_PASSWORD: StrongPass2026
POSTGRES_DB: directus
cache:
image: redis:7-alpine
restart: always
directus:
image: directus/directus:11
ports:
- "127.0.0.1:8055:8055"
volumes:
- ./uploads:/directus/uploads
- ./extensions:/directus/extensions
depends_on:
- database
- cache
environment:
KEY: "RandomKey2026LongEnough"
SECRET: "RandomSecret2026LongEnough"
DB_CLIENT: pg
DB_HOST: database
DB_PORT: 5432
DB_DATABASE: directus
DB_USER: directus
DB_PASSWORD: StrongPass2026
CACHE_ENABLED: "true"
CACHE_STORE: redis
REDIS: redis://cache:6379
ADMIN_EMAIL: [email protected]
ADMIN_PASSWORD: ChangeMeNow
EOF
docker compose up -dĐặt Nginx hoặc Traefik phía trước với HTTPS Let's Encrypt. Truy cập admin panel qua HTTPS, đăng nhập với admin email và đổi password ngay. Tạo collection mới hoặc import schema từ database hiện có - Directus auto-detect table và sinh API tương ứng.
Permission, Flow Automation Và Tích Hợp
Permission Directus chi tiết đến field level. Tạo role "Editor" với policy: collection "articles" cho phép read + create + update nhưng không delete, field "status" chỉ admin sửa được, field "author" auto-set bằng user hiện tại qua hook. Cách này ngăn nhân sự xóa nhầm hoặc tự ý publish.
Flow automation (tương đương Zapier built-in) là tính năng cực mạnh của Directus. Tạo trigger "khi article được publish" - gửi webhook cho frontend Next.js để rebuild trang static, gửi email cho subscriber qua API Mailgun, post lên Telegram channel qua bot. Flow không cần code - drag and drop operation kết nối các step.
Tích hợp frontend qua SDK @directus/sdk:
import { createDirectus, rest, readItems } from '@directus/sdk';
const client = createDirectus('https://cms.example.com').with(rest());
const articles = await client.request(readItems('articles', { fields: ['*'], limit: 10 }));GraphQL endpoint cũng có sẵn tại /graphql. Public role có thể được cấu hình cho phép read-only một số collection - frontend gọi trực tiếp từ browser không cần API token. Backup PostgreSQL database hằng đêm với pg_dump, kèm folder /opt/directus/uploads chứa media. Sync về VPS bkp AnubizHost với encryption GPG đảm bảo recovery trong dưới 30 phút khi cần.
Related Services
Why Anubiz Host
Ready to get started?
Skip the research. Tell us what you need, and we'll scope it, implement it, and hand it back — fully documented and production-ready.