How to Install DirectoryLister on NixOS

DirectoryLister is an open-source web-based application that creates listings of directories on a web server. In this tutorial, we will explain how to install DirectoryLister on NixOS.

Prerequisites

Before proceeding with the installation of DirectoryLister, you should have the following prerequisites installed on your system:

  • NixOS Latest
  • Apache or Nginx web server
  • PHP 5.5 or later
  • Git

Step 1: Install Git

To install Git on NixOS, run the following command:

$ sudo nix-env -i git

Step 2: Clone the DirectoryLister Repository

Clone the DirectoryLister repository to your web server with the following command:

$ git clone https://github.com/DirectoryLister/DirectoryLister.git /var/www/DirectoryLister

Step 3: Install PHP

Install PHP 7.4 with the following command:

$ sudo nix-env -i php composer

Step 4: Install Dependencies

Navigate to the /var/www/DirectoryLister directory and install the dependencies with the following command:

$ cd /var/www/DirectoryLister
$ composer install

Step 5: Configure Apache or Nginx

Apache Configuration

Create a new VirtualHost file for DirectoryLister with the following command:

$ sudo nano /etc/httpd/conf.d/directorylister.conf

And add the following configuration:

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/DirectoryLister
    <Directory /var/www/DirectoryLister>
        Options FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    ErrorLog /var/log/httpd/directorylister-error.log
    CustomLog /var/log/httpd/directorylister-access.log combined
</VirtualHost>

Restart Apache with the following command:

$ sudo systemctl restart httpd

Nginx Configuration

Create a new server block for DirectoryLister with the following command:

$ sudo nano /etc/nginx/sites-available/directorylister

And add the following configuration:

server {
    listen 80;
    listen [::]:80;
    server_name directorylister.example.com;
    root /var/www/DirectoryLister;
    index index.php;
    location / {
        try_files $uri $uri/ /index.php?$args;
    }
    location ~ \.php$ {
        fastcgi_pass unix:/run/php/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
    error_log /var/log/nginx/directorylister-error.log;
    access_log /var/log/nginx/directorylister-access.log;
}

Create a symbolic link to enable the new server block with the following command:

$ sudo ln -s /etc/nginx/sites-available/directorylister /etc/nginx/sites-enabled/

Test Nginx configuration with the following command:

$ sudo nginx -t

Restart Nginx with the following command:

$ sudo systemctl restart nginx

Step 6: Access DirectoryLister

Now you can access DirectoryLister from your web browser by going to http://your-server-ip or https://your-server-ip if you have HTTPS enabled.

Congratulations! You have successfully installed DirectoryLister on NixOS.