How to install Kleeja on nixOS Latest

Kleeja is a powerful and easy-to-use file upload system that allows you to host your own file sharing website. In this tutorial, we will show you how to install Kleeja on nixOS Latest.

Prerequisites

Before we start the installation process, make sure that you have the following prerequisites:

Step 1 - Download Kleeja

To download the latest version of Kleeja, visit the official website, and click on the "Download" button. Once the download is complete, extract the Kleeja archive to your desired location.

Step 2 - Install PHP and other dependencies

Kleeja requires PHP to run on your server. You can install PHP and its dependencies, along with the web server, using the following command:

sudo nix-env -iA nixos.apacheHttpd nixos.php

This command will install the Apache HTTP server and PHP on your system.

Step 3 - Configure Apache

Once PHP and Apache are installed, you need to configure Apache to work with Kleeja. You can do this by creating a new Apache virtual host configuration. Create a new file under /etc/nixos/ with the following contents:

{ config, pkgs, ... }:

let
  phpCfg = pkgs.writeText "phpCfg" ''
    upload_max_filesize = 50M
    post_max_size = 50M
  '';
in

{
  services.httpd = {
    enable = true;
    adminAddr = "admin@example.com";
    virtualHosts."example.com" = {
      enableACME = true;
      forceSSL = true;
      locations."/" = {
        root = "${pkgs.kleeja}/htdocs";
        index = "index.php index.html";
        php = true;
        extraConfig = ''
          php_admin_flag engine on
          php_admin_flag safe_mode off
          php_admin_flag register_globals off
          php_admin_flag file_uploads on
          php_admin_flag short_open_tag on
          php_admin_flag display_errors on
          php_admin_flag display_startup_errors on
          php_admin_value error_reporting E_ALL & ~E_NOTICE & ~E_DEPRECATED
          php_admin_value max_execution_time 300
          php_admin_value upload_max_filesize 50M
          php_admin_value post_max_size 50M
          ${phpCfg}
        '';
      };
    };
  };
}

Be sure to replace example.com with your domain name.

Step 4 - Configure Kleeja

Navigate to the Kleeja/config.php file and open it in your text editor. Uncomment the following lines and enter your MySQL database credentials:

define('DB_HOST', 'localhost');
define('DB_USER', 'username');
define('DB_PASS', 'password');
define('DB_NAME', 'databasename');

Save the changes and close the file when you are done.

Step 5 - Start Apache and MySQL

Run the following command to start Apache and MySQL:

sudo systemctl start httpd mysql

Step 6 - Access Kleeja

Open your web browser and enter your domain name. You will be directed to the Kleeja installation page. Follow the on-screen instructions to complete the installation.

Congratulations! You have successfully installed Kleeja 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!