How to Install Lychee on NixOS Latest

Lychee is a free, open-source photo management software that allows you to easily upload, organize, and share your photos. In this tutorial, we will guide you through the process of installing Lychee on NixOS Latest.

Prerequisites

Before we start, make sure you have the following:

Step 1 - Install Required Packages

Before installing Lychee, we need to ensure that our system has the required packages installed. Open your terminal and enter the following command:

sudo nix-env -i php php-fpm php-opcache php-gd nginx

This command will install PHP, the FastCGI Process Manager, the PHP opcache extension, the GD library, and the Nginx web server.

Step 2 - Install MariaDB

Lychee requires a database to store its data. In this tutorial, we will be using MariaDB. Install MariaDB by running the following command:

sudo nix-env -i mariadb

Step 3 - Create a MariaDB Database and User

Next, we need to create a MariaDB database and user for Lychee. Start by opening the MariaDB prompt by running the following command:

sudo mysql -u root

Once you're inside the prompt, create a new database and user by entering the following commands:

CREATE DATABASE lychee_db;
CREATE USER 'lychee_user'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON lychee_db.* TO 'lychee_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Make sure to replace 'password' with a strong password of your choice.

Step 4 - Download and Install Lychee

We're almost there! To download and install Lychee, navigate to your web root directory:

cd /var/www

Next, download Lychee and extract it into your web root directory:

sudo curl -sSL https://github.com/LycheeOrg/Lychee/archive/master.tar.gz | sudo tar -xz -C /var/www/
sudo mv /var/www/Lychee-master /var/www/lychee

Finally, set the correct permissions:

sudo chown -R nginx:nginx /var/www/lychee
sudo chmod -R 755 /var/www/lychee

Step 5 - Configure Nginx

Lastly, we need to configure Nginx to serve Lychee. Open your Nginx configuration file:

sudo nano /etc/nginx/nginx.conf

Find the "http" section and add the following code:

server {
    listen       80 default_server;
    server_name  your_domain.com; # Replace with your domain name or IP address
    root /var/www/lychee/public;
    index index.html index.php;
    error_log /var/log/nginx/lychee_error.log;
    access_log /var/log/nginx/lychee_access.log;

    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  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

Remember to replace 'your_domain.com' with your actual domain name or IP address.

Save the configuration file and restart Nginx:

sudo systemctl restart nginx

Step 6 - Access Your Lychee Installation

Lychee should now be accessible from your web browser. If you installed Lychee on a server with a public IP address or hostname, enter your server's IP address or hostname into your browser's address bar. If you're accessing it locally, you can use:

http://localhost/lychee/

Once you've navigated to your Lychee installation, follow the setup wizard to finish the installation process.

Congratulations! You've successfully installed Lychee on NixOS Latest. Now you can start uploading and organizing your photos!

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!