How to Install Directus Locally
Ever wondered how to install Directus locally without having to run a bloated Docker container. You can get started within 5 minutes using these simple steps. This assumes NodeJS is installed.
To install Directus locally, install a SQL database or have a cloud instance ready, run npm install directus
in the project directory, then run npx directus init
. This will guide you through the initial configuration. Once complete, run npx directus start
and Directus will be available http://127.0.0.1:8055.
Step 1: Set up a Database
Directus supports a great range of databases. SQLite is the simplest solution for a local set up otherwise you can consider installing MySQL or PostgreSQL. Another option is to use a SQL cloud provider like:
- CockroachSQL
- Google Cloud Hosting
- AWS
- Microsoft Azure
- Digital Ocean
The main thing to ensure with cloud hosting is that you have a secure encrypted connection (https) between your local install and the cloud host.
Step 2: Install Directus
Create a project directory and open a terminal in this directory. Run the following command:
npm install directus
This will install all the dependencies into the current directory.
Step 3: Initialize Directus
Now that Directus is installed, run the following command:
npx directus init
This will ask a series of questions and build a .env file in your project directory. First, choose the database client to use with Directus. The database must already be set up with credentials before completing this step, the exception being SQLite.
Choose your database client (Use arrow keys)
❯ PostgreSQL / Redshift
CockroachDB (Beta)
MySQL / MariaDB / Aurora
SQLite
Microsoft SQL Server
Oracle Database
Depending on the SQL solution, you will be asked to provide connection details such as the host, port and authentication or file path for SQLite. This information is written to the .env file.
Next, you will be asked to set up the admin user. This will be written to the SQL database along with the default schema for Directus.
Create your first admin user:
Email ([email protected])
Password ************
And that's it. Directus is now configured and ready to start.
Step 4: Start Directus
From the project directory, run the following command:
npx directus start
When started, it will output the address to use in the browser like so:
INFO: Server started at http://0.0.0.0:8055
However 0.0.0.0 won't work, use the following address instead: http://127.0.0.1:8055
Login with your credentials created in Step 3.
Note: If you get the following warnings, simply create these missing folders inside your project directory and restart Directus.
WARN: Upload directory (/path/to/project/uploads) is not read/writeable!
WARN: Extensions directory (/path/to/project/extensions) is not readable!
Additional
Directus will be running as long as your terminal is open. If you need to restart Directus, without closing the terminal, press Crtl+C
, then run npx directus start
again.
Conclusion
After following these steps, you have Directus installed locally and accessible in your browser. Also, your chose database will have the default schema for Directus.