How to install Directus on Debian Latest
Directus is an open-source toolkit that helps you build custom database-driven APIs, without requiring any coding skills. In this tutorial, we will guide you through the process of setting up Directus on a Debian server, step by step.
Prerequisites
Before we start, please make sure that you have:
- A Debian server (version 10 or later)
- A non-root user with sudo privileges
- Access to the terminal, either locally or through SSH
Step 1: Update the System
Let's start with updating the system packages to the latest version:
sudo apt update && sudo apt upgrade -y
Step 2: Install Required Packages
Directus requires a few packages to be installed on your system before it can run correctly. Run the following command to install the packages:
sudo apt install curl wget gnupg2 ca-certificates apt-transport-https -y
Step 3: Install and Configure MariaDB
Directus requires a database to store its data. We will use MariaDB, a popular MySQL database fork, for this purpose. Install MariaDB by running the following command:
sudo apt install mariadb-server mariadb-client -y
Once the installation is complete, run the following command to secure your database server:
sudo mysql_secure_installation
You will be prompted for a few options, such as setting a root password, removing anonymous users, etc. Follow the prompts and answer them as per your requirements.
Now, let's create a new database and user for Directus:
sudo mysql -u root -p
This will open the MariaDB prompt. Enter the following commands to create a new database and user:
CREATE DATABASE directus;
GRANT ALL PRIVILEGES ON directus.* TO 'directus'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
EXIT;
Replace 'password' with a secure password of your choice.
Step 4: Install Directus
We will now install Directus using the official Directus package repository. Run the following commands:
curl -s https://get.directus.io/ | sudo bash
sudo apt update
sudo apt install directus-cli -y
Step 5: Initialize Directus
Now that we have installed Directus, we need to initialize it. Run the following command to initialize Directus and provide the database details:
sudo directus init --db=mysql --host=localhost --name=directus --username=directus --password=password
Replace 'password' with the Secure Password you had set earlier.
Step 6: Start Directus
Once the initialization is complete, start the Directus server by running the following command:
sudo directus start
You should now be able to access Directus by visiting http://your_server_ip:8055 (replace your_server_ip with your actual server IP address).
Conclusion
That's it! You have successfully installed Directus on your Debian server. You can now use Directus to create custom database-driven APIs for your applications. If you face any issues during the installation or configuration process, please refer to the official Directus documentation for additional help.