UbuntuUbuntu Based

How To Install Lychee on Ubuntu 24.04 LTS

In today’s digital age, managing and organizing our ever-growing collection of photos has become increasingly important. Lychee, an open-source photo management solution, offers a sleek and user-friendly platform for storing, organizing, and sharing your precious memories. This guide will walk you through the process of installing Lychee on Ubuntu 24.04, empowering you to take control of your digital photo library.

Self-hosting Lychee not only provides enhanced privacy and security for your personal photos but also gives you complete control over your data. By following this step-by-step tutorial, you’ll be able to set up your own Lychee instance and enjoy a feature-rich photo management system tailored to your needs.

Prerequisites

Before we dive into the installation process, let’s ensure you have everything needed to successfully set up Lychee on your Ubuntu 24.04 system. Here’s what you’ll need:

  • A server or computer running Ubuntu 24.04 LTS
  • Root or sudo access to the system
  • A stable internet connection
  • Basic familiarity with the Linux command line

Lychee relies on the LAMP stack (Linux, Apache, MySQL, PHP) to function properly. We’ll be installing these components as part of the process. Additionally, you’ll need Git for cloning the Lychee repository and wget for downloading files.

Installation Steps

Now that we’ve covered the prerequisites, let’s walk through the installation process step by step. We’ll start by updating your system and then move on to setting up the LAMP stack before finally installing and configuring Lychee.

Step 1: Update System Packages

It’s crucial to start with an up-to-date system. Open your terminal and run the following commands:

sudo apt update
sudo apt upgrade -y

These commands will update your package lists and upgrade all installed packages to their latest versions. Keeping your system updated ensures compatibility and security for the software we’ll be installing.

Step 2: Install LAMP Stack

The LAMP stack is the foundation for running Lychee. Let’s install each component:

Install Apache

Apache will serve as our web server. Install it using:

sudo apt install apache2 -y

After installation, start and enable Apache:

sudo systemctl start apache2
sudo systemctl enable apache2

Install MySQL

MySQL will be our database management system. Install it with:

sudo apt install mysql-server -y

Install PHP and Required Extensions

Lychee requires PHP and several PHP extensions. Install them using:

sudo apt install php libapache2-mod-php php-mysql php-gd php-curl php-mbstring php-imagick php-zip php-exif -y

After installation, restart Apache to apply the changes:

sudo systemctl restart apache2

Step 3: Configure MySQL

Now that MySQL is installed, we need to secure it and create a database for Lychee:

Secure MySQL

Run the MySQL secure installation script:

sudo mysql_secure_installation

Follow the prompts to set a root password and remove insecure default settings.

Create Lychee Database and User

Log into MySQL as root:

sudo mysql -u root -p

Create a database and user for Lychee:

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

Replace ‘your_password’ with a strong, unique password.

Step 4: Adjust PHP Settings

Lychee requires specific PHP settings for optimal performance. Edit the php.ini file:

sudo nano /etc/php/8.1/apache2/php.ini

Find and modify the following lines:

memory_limit = 512M
post_max_size = 100M
upload_max_filesize = 100M
max_execution_time = 200

Save the file and exit the editor.

Step 5: Download and Install Lychee

Now we’re ready to install Lychee itself:

Clone Lychee Repository

cd /var/www/html
sudo git clone https://github.com/LycheeOrg/Lychee.git lychee
cd lychee

Install Composer

Lychee uses Composer for dependency management. Install it with:

sudo apt install composer -y

Install Lychee Dependencies

sudo composer install --no-dev

Set Permissions

sudo chown -R www-data:www-data /var/www/html/lychee
sudo chmod -R 775 /var/www/html/lychee/storage
sudo chmod -R 775 /var/www/html/lychee/public/uploads
sudo chmod -R 775 /var/www/html/lychee/public/dist

Step 6: Configure Apache for Lychee

Create a new Apache virtual host configuration for Lychee:

sudo nano /etc/apache2/sites-available/lychee.conf

Add the following content:

<VirtualHost *:80>
    ServerName your_domain.com
    DocumentRoot /var/www/html/lychee/public

    <Directory /var/www/html/lychee/public>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/lychee_error.log
    CustomLog ${APACHE_LOG_DIR}/lychee_access.log combined
</VirtualHost>

Replace ‘your_domain.com’ with your actual domain or server IP address.

Enable the new site and reload Apache:

sudo a2ensite lychee.conf
sudo a2enmod rewrite
sudo systemctl reload apache2

Step 7: Finalizing Installation

Open your web browser and navigate to http://your_domain.com or http://your_server_ip. You should see the Lychee setup page.

Follow the on-screen instructions to complete the installation:

  1. Enter your database details (database name, username, and password).
  2. Create an admin account for Lychee.
  3. Configure your preferred settings.

Once completed, you’ll be redirected to the Lychee login page. Log in with your newly created admin account to start using Lychee!

Install Lychee on Ubuntu 24.04

Troubleshooting

If you encounter any issues during the installation process, here are some common problems and their solutions:

Database Connection Error

If Lychee can’t connect to the database, double-check your database credentials in the .env file:

sudo nano /var/www/html/lychee/.env

Ensure the DB_DATABASE, DB_USERNAME, and DB_PASSWORD values are correct.

Permission Issues

If Lychee can’t write to certain directories, revisit the permissions step and ensure all necessary directories have the correct permissions set.

PHP Extension Missing

If you receive an error about a missing PHP extension, install it using:

sudo apt install php-[extension_name]

Replace [extension_name] with the name of the missing extension.

Congratulations! You have successfully installed Lychee. Thanks for using this tutorial for installing Lychee self-hosted photo management on Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the official Lychee website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button