Installing Directus 6 on LAMP
Before you can experience all of the awesome features within Directus, you first need to install it. In this article, I’ll show you how to get started with Directus.
Note: this tutorial is specific to Directus v6.
This tutorial assumes you have a LAMP (Linux, Apache, MySQL, PHP) stack pre-installed. If you don’t have a server yet, I highly recommend getting a DigitalOcean droplet with a LAMP one-click install.
If you already have a VPS with a clean Ubuntu installation, I recommend you follow this tutorial on installing the LAMP stack.
The following steps should work for other versions of Ubuntu, and even other operating systems, but bear in mind that not all of these combinations have been tested.
Installing Directus using SSH & Git (recommended)
PHP, Apache & MySQL setup
Directus requires PHP’s cUrl extension to be installed, so let's start by installing that:sudo apt-get install php-curl
Enable Apache mod_rewrite
extension by running sudo a2enmod rewrite
and adding:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
to your Apache config file which is located at /etc/apache2/sites-available/default
.
Make sure to restart the apache2 service afterwards by running: sudo systemctl restart apache2
Directus does not fully support Strict Mode due to limitations with the PDO and MySQL Drivers. Disable MySQL Strict Mode by creating a new file /etc/mysql/conf.d/disable_strict_mode.cnf
which contains the following two lines:
[mysqld]
sql_mode=IGNORE_SPACE,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Restart the MySQL service afterwards by running sudo systemctl restart mysql
.
Cloning Directus from GitHub
Next up, navigate to /var/www/html
by running cd /var/www/html
. This is Apache’s default public folder in which we’ll install Directus.
Next up, clone Directus from GitHub as follows:git clone https://github.com/directus/directus.git
This clones the master branch of Directus to a folder called directus
which means your Directus instance will be available at http://{{your_ip_address}}/directus
.
Note: the owner of the directus
folder may be set to root
if you clone Directus directly. Make sure to change the owner back to www-data
otherwise Directus won’t have write-access to important locations like /uploads
. You can reset the permissions by running sudo chown www-data -R /var/www/html/directus
Installing Composer dependencies
Directus is built using a number of external packages and dependencies. To install these, we use a utility named Composer — a package manager for PHP. If you don’t already have composer, you can install it by running apt install composer
. Composer uses the zip and unzip Ubuntu packages for some operations, so it’s also recommended to install those by running apt install zip unzip php7.0-zip
(replace the 7.0
bit with your current version of PHP. Run php -v
to find out which version you’re running).
Once you have Composer, it’s time to install Directus’ dependencies by navigating to the directus
directory and running composer install
.
My particular setup gave an error about a missing PHP-extension called
ext-dom
. I fixed this by installingphp-xml
withsudo apt-get install php-xml
.
Installing Directus via FTP
If you don’t have access to your server’s command line, Directus provides a pre-built version with the Composer dependencies already installed.
For Directus to function properly you still need to make sure your hosting provider supports all of the required extensions — listed here on the Directus readme).
To install Directus using this pre-built version, download the latest version from the releases page and upload it to your server with (S)FTP.
With Directus now installed, you’re ready to start creating something amazing!
Your friends at Directus
🐰