Directus

Directus is a real-time API and App dashboard for managing SQL database content.


Note

For this guide you should be familiar with the basic concepts of

License

All relevant legal information can be found here in the GitHub repository of the project:

Prerequisites

Node and npm

We’re using Node.js, its package manager npm:

[isabell@stardust ~]$ uberspace tools version show node
Using 'Node.js' version: '16'
[isabell@stardust ~]$ npm --version
7.20.0
[isabell@stardust ~]$

Installation

Update npm to the latest stable version. This includes npx (to execute npm package binaries).

[isabell@stardust ~]$ npm install --global npm@latest
[isabell@stardust ~]$

Create directory directus and sub directory logs.

[isabell@stardust ~]$ mkdir -p ~/directus/logs
[isabell@stardust ~]$

Note

As CentOS 7 (uberspace) only provides glibc 2.17, the argon2 module on needs to be manually recompiled. This will avoid Error: /lib64/libc.so.6: version GLIBC_2.25

[isabell@stardust ~]$ cd ~/directus
[isabell@stardust directus]$ npm install @mapbox/node-pre-gyp argon2
[isabell@stardust directus]$ npx node-pre-gyp rebuild -C ./node_modules/argon2
[isabell@stardust directus]$

Installation and initialize a new instance of Directus

[isabell@stardust ~]$ cd ~/directus
[isabell@stardust directus]$ npm install directus
[isabell@stardust directus]$ npx directus init
? Choose your database client
  PostgreSQL / Redshift
  MySQL / MariaDB / Aurora
❯ SQLite
  Microsoft SQL Server
  Oracle Database (Alpha)
⠹ Installing Database Driver...
? Choose your database client SQLite
? Database File Path: (/home/isabell/directus/data.db)
Create your first admin user:
? Email admin@example.com
? Password **********
Your project has been created at /home/isabell/directus.
The configuration can be found in /home/isabell/directus/.env
[isabell@stardust directus]$

Configuration

Setup daemon

Create ~/etc/services.d/directus.ini with the following content:

[program:directus]
process_name=%(program_name)s
directory=%(ENV_HOME)s/directus
command=%(ENV_HOME)s/bin/npx directus start
autostart=true
autorestart=true
environment=NODE_ENV=production
startsecs=60
stderr_logfile=%(ENV_HOME)s/logs/%(program_name)s.err.log
stdout_logfile=%(ENV_HOME)s/logs/%(program_name)s.out.log

After creating the configuration, tell supervisord to refresh its configuration and start the service:

[isabell@stardust ~]$ supervisorctl reread
SERVICE: available
[isabell@stardust ~]$ supervisorctl update
SERVICE: added process group
[isabell@stardust ~]$ supervisorctl status
SERVICE                            RUNNING   pid 26020, uptime 0:03:14
[isabell@stardust ~]$

If it’s not in state RUNNING, check your configuration.

Updates

Check GitHub repository of the project regularly to stay informed about the newest version. To update an existing installation use the following commands:

[isabell@stardust ~]$ cd ~/directus
[isabell@stardust directus]$ supervisorctl stop directus
[isabell@stardust directus]$ npx --yes npm-check-updates --upgrade
[isabell@stardust directus]$ npm install
[isabell@stardust directus]$ npx node-pre-gyp rebuild -C ./node_modules/argon2
[isabell@stardust directus]$ npx directus database migrate:latest
[isabell@stardust directus]$ supervisorctl start directus
[isabell@stardust directus]$

Tested with directus v9.0.0-rc.89, Uberspace 7.11.3

Written by: j3n57h0m45 <https://github.com/j3n57h0m45>