How to Install Lychee on Alpine Linux Latest

Lychee is a self-hosted photo management tool that lets you upload, organise and share your photos online. This tutorial will walk you through the steps to install and configure Lychee on Alpine Linux latest.

Prerequisites

Before starting this tutorial, you should have:

Step 1: Install MariaDB

Lychee requires a database to store its data. We will be using MariaDB in this tutorial as it is a fully compatible drop-in replacement for MySQL.

To install MariaDB, run the following command:

sudo apk add mariadb mariadb-client

Once the installation is complete, start the MariaDB service and set it to start on boot with the following commands:

sudo rc-update add mariadb default
sudo /etc/init.d/mariadb start

Now that MariaDB is up and running, it's time to create a database and user for Lychee.

Step 2: Create MariaDB Database and User for Lychee

First, log in to the MariaDB server as the root user with the following command:

sudo mysql -u root -p

You will be prompted for the root password. Enter it and press Enter.

Next, create a new database and user for Lychee with the following commands. Be sure to change lycheeuser and lycheepassword to your desired values.

CREATE DATABASE lycheedb;
GRANT ALL PRIVILEGES ON lycheedb.* TO 'lycheeuser'@'localhost' IDENTIFIED BY 'lycheepassword';
FLUSH PRIVILEGES;
exit

Step 3: Install Lychee

To install Lychee, you will need to download the archive from the Lychee website and extract it to your web server's document root directory.

Assuming your web server document root is /var/www/htdocs, run the following commands to download and extract the Lychee archive:

cd /var/www/htdocs
sudo wget https://github.com/LycheeOrg/Lychee/archive/master.zip
sudo unzip master.zip
sudo mv Lychee-master lychee

Next, set the correct file permissions for Lychee with the following command:

sudo chown -R www-data:www-data lychee/

Note: If your web server user is not www-data, replace it with the appropriate user.

Step 4: Configure Lychee

Lychee comes with a sample configuration file that you will need to modify. First, make a copy of the sample configuration file with the following command:

sudo cp /var/www/htdocs/lychee/data/config.php.sample /var/www/htdocs/lychee/data/config.php

Next, edit the config.php file with your preferred text editor. For example, to use the Nano editor, run the following command:

sudo nano /var/www/htdocs/lychee/data/config.php

In the config.php file, make the following changes:

// Database configuration
$dbHost     = 'localhost';
$dbUser     = 'lycheeuser';
$dbPassword = 'lycheepassword';
$dbName     = 'lycheedb';
// Set a passphrase to secure your installation
$config['password'] = 'your_secret_passphrase';

Once you have made the necessary changes to the configuration file, save and close the file.

Step 5: Access Lychee

With Lychee installed and configured, you should now be able to access it through your web browser. If you are using Nginx as your web server, create a new Nginx configuration file with the following command:

sudo nano /etc/nginx/conf.d/lychee.conf

In the file, add the following Nginx configuration:

server {
    listen 80;
    server_name yourdomain.com; #replace with your domain or IP address
    root /var/www/htdocs/lychee/;
    index index.php;

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

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

Save and close the file, then restart the Nginx service to apply the changes:

sudo /etc/init.d/nginx restart

You should now be able to access Lychee by navigating to http://yourdomain.com/lychee in your web browser (replace yourdomain.com with your domain or IP address).

Conclusion

Congratulations! You have successfully installed and configured Lychee on Alpine Linux latest. Lychee is a powerful photo management tool that can help you organise and share your photos online. Take the time to explore its features and customise it to your needs. Happy photo management!

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!