Trax is a no-frills learning record store (LRS) designed for gathering and storing xAPI data. It’s open-source and a great way to dip your toes into the world of the Experience API.
I wanted to take Trax for a spin, so I installed it on a DigitalOcean droplet. My installation is configured for production (not limited to localhost) and includes a domain name and HTTPS. Here are the steps I used to install and configure Trax.
Create an Ubuntu Droplet in DigitalOcean
From your DigitalOcean account, click Create then select Droplets. The Create Droplets page will appear.
Choose your region (I selected San Francisco), then choose Ubuntu. At the time of this writing, the latest long-term support edition is Ubuntu 24.04 LTS x64.
Droplet Size
To keep costs down, I selected a shared CPU with a regular SSD. If this were a true production system, I would have opted for a dedicated CPU. Trax LRS should work fine with the cheapest 2GB RAM package (50GB SSD, 2TB transfer). At the time of this writing, this configuration costs $12/month. The droplet specs can always be beefed up later if needed.
New to DigitalOcean? Use my affiliate link for $200 of free credit!
Authentication Method
The authentication method is up to you, but I use the SSH key option for convenience.
Finalize Details
Edit the droplet’s Hostname field to whatever works for you. This is just for your own reference within your DigitalOcean account. Click the Create Droplet button to complete the process.
Once the droplet has been generated, you will see its IP address in your DigitalOcean dashboard. Make a note of the IP address, we will need it in future steps.
Configure your domain name
Go to your registrar of choice (I use porkbun.com) and configure your domain as needed. Use the droplet’s IP address for the A record. I won’t be providing instructions for configuring the domain, as each registrar uses slightly different workflows.
Install Trax
Connect to the droplet via SSH and prep the system
SSH to your droplet using your terminal of choice (I use Warp) and your droplet’s IP address. For example:
ssh root@123.123.123.123
Code language: Bash (bash)
Note: For simplicity, this tutorial will be running commands as the root user. The best practice in Linux environments is to create an admin user on the system, SSH into the system as that user, then run the same commands, but prefixed with sudo
. If you plan to use these instructions for a true production environment, please set up an admin account and avoid using root.
Once connected, ensure the system is up to date by running
apt update && apt upgrade
Code language: Bash (bash)
Install dependencies
Trax has a number of dependencies, including PHP and a database (I’m using MariaDB instead of MySQL). Install the dependencies using the following command:
apt install apache2 php libapache2-mod-php php-mysql php-curl php-xml php-mbstring php-zip php-gd mariadb-server git composer certbot python3-certbot-apache
Code language: Bash (bash)
Note: If this were a true production system, I would use a dedicated database server.
Harden MariaDB
For safety, let’s take a moment to secure the MariaDB installation.
Run the following command, then follow the prompts as needed. If you elect to configure a password for the MariaDB root user, be sure to write it down as you will need it later.
mysql_secure_installation
Code language: Bash (bash)
Install the Trax files
Grab the Trax files from its GitHub repository, then run the Trax install script.
git clone https://github.com/trax-project/trax2-starter-lrs /var/www/traxlrs
cd /var/www/traxlrs
composer install
Code language: Bash (bash)
Note: As previously mentioned, this tutorial is using the Ubuntu root account. If you’re following the tutorial step by step, you will see a warning about running composer
as a root user. For this demo, it’s safe to ignore the warning. If you’re setting up a true production environment, you should not be using root.
Set permissions
Now that the Trax files and directories are in place, we need to ensure permissions are correct. I used the following configuration, though you may be able to lock it down further, if desired:
chown -R www-data:www-data storage bootstrap/cache
chmod -R 755 storage
chmod -R 755 bootstrap/cache
Code language: Bash (bash)
Configure Apache
There are several things that need to be configured for Apache. First, let’s configure the virtual host:
nano /etc/apache2/sites-available/traxlrs.conf
Code language: Bash (bash)
This will bring up the virtual host settings in the nano text editor. Insert the following snippet. Be sure to modify the ServerAdmin and ServerName fields for your environment:
<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot /var/www/traxlrs/public
ServerName example.com
<Directory /var/www/traxlrs/public>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Code language: Apache (apache)
Save the file and exit nano. (If you’re unfamiliar with nano, you can press control-x on your keyboard to exit, which prompts you to save changes. Type Y to save changes, then press Enter to save the file using the existing file name.)
Next, enable the site and rewrite module:
a2ensite traxlrs.conf
a2enmod rewrite
systemctl restart apache2
Code language: Bash (bash)
Configure the database
MariaDB was installed, but we haven’t set up the Trax database yet. Log in to MariaDB:
sudo mysql -u root -p
Code language: Bash (bash)
If you created a password for the MariaDB root user, enter it now.
You should see the SQL prompt in your terminal. Edit the following to use a proper password for ‘traxuser’, then paste into the SQL prompt and press enter.
CREATE DATABASE traxlrs CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'traxuser'@'localhost' IDENTIFIED BY 'YourSecurePassword';
GRANT ALL PRIVILEGES ON traxlrs.* TO 'traxuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Code language: SQL (Structured Query Language) (sql)
Update the environment file
Trax comes with a sample environment file. It’s a great starting point, so let’s copy it, then edit it to fit our needs:
cp .env.example .env
nano .env
Code language: Bash (bash)
In the nano editor, update the file to reflect the latest info. Be sure to include your actual database password.
DB_DATABASE=traxlrs
DB_USERNAME=traxuser
DB_PASSWORD=YourSecurePassword
Code language: Bash (bash)
We’ll be coming back to the environment file in a moment. For now, save and exit.
Finalize Trax installation
Run the following commands to finalize the Trax installation:
php artisan key:generate
php artisan migrate
Code language: Bash (bash)
Let’s create a Trax admin account:
php artisan admin:create
Code language: Bash (bash)
Set environment to production
Since this is a public-facing installation and not running locally on your machine, we need to update the environment file to production values. Open the .env file again:
nano .env
Code language: Bash (bash)
Then update the following values:
APP_ENV=production
APP_DEBUG=false
Code language: Bash (bash)
Save and exit.
Optimize the installation
Run these commands to do some quick optimization:
php artisan config:cache
php artisan route:cache
Code language: Bash (bash)
Enable HTTPS
We’re almost done! The Trax system should be up and running, but we should ensure it’s using HTTPS. We’ll use Let’s Encrypt, which makes HTTPS easy. Run the following command then follow the prompts. Be sure to use your actual domain name, not example.com!
certbot --apache -d example.com
Code language: Bash (bash)
Once you’ve completed the certbot prompts, your Trax system should be up and running at your specified domain.