How to Install Leantime on nixOS Latest

This tutorial will guide you through the installation steps of Leantime on nixOS Latest.

Prerequisites

Step 1: Install Dependencies

The first step is to install the required dependencies for Leantime. You can do this by running the following command:

sudo nix-env -iA nixos.mariadb nixos.nginx

Step 2: Download Leantime

Next, we need to download the latest Leantime release from their website. Run the following command to download the latest Leantime release:

wget https://github.com/Leantime/leantime/releases/latest/download/leantime-latest.zip

Step 3: Extract Leantime

After downloaded the release, extract it using the following command:

sudo unzip leantime-latest.zip -d /var/www/leantime

Step 4: Create a Database

Create a new MySQL database and user for Leantime.

sudo mysql -u root -p

CREATE DATABASE leantime;
GRANT ALL PRIVILEGES ON leantime.* TO 'leantimeuser'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
exit;

Step 5: Configure Nginx

Create a new Nginx configuration file for Leantime.

sudo nano /etc/nginx/sites-available/leantime

And paste the following configuration into the new file.

server {
    listen 80;
    server_name leantime.example.com;

    root /var/www/leantime/public;
    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Save and close the file.

Now, enable our new Nginx site and restart Nginx.

sudo ln -s /etc/nginx/sites-available/leantime /etc/nginx/sites-enabled/
sudo systemctl restart nginx

Step 6: Configure Leantime

Create a new configuration file for Leantime.

sudo cp /var/www/leantime/.env.example /var/www/leantime/.env
sudo nano /var/www/leantime/.env

In the new file, set the following variables:

APP_URL=http://leantime.example.com
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=leantime
DB_USERNAME=leantimeuser
DB_PASSWORD=password

Save and close the file.

Step 7: Install Composer

Leantime requires Composer for package management. Install Composer by running the following command:

sudo nix-env -iA nixos.composer

Step 8: Install PHP Packages

Install the PHP packages for Leantime by running the following command:

cd /var/www/leantime
sudo composer install

Step 9: Run Database Migrations

Run the Leantime database migrations.

cd /var/www/leantime
php artisan migrate

Step 10: Serve the Leantime Site

Finally, serve the Leantime site by running:

cd /var/www/leantime
sudo php artisan serve

You can now access the Leantime web interface by visiting the URL you have configured in the Nginx configuration file.

Congratulations! You have successfully installed Leantime on nixOS Latest.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!