Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Set Up Linux Photo Management with Lychee

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Yes, you can set up a self-hosted photo management system on Linux using Lychee — a free, open-source web app that organizes, tags, and shares your photos. This guide walks you through installing Lychee on Ubuntu (or Debian-based) Linux with Nginx, PHP, and MySQL/MariaDB. You'll end up with a private photo library accessible from any browser on your network, with optional public sharing.

What You'll Need

  • A Linux server or PC running Ubuntu 20.04 or newer (or Debian 10+).
  • Root or sudo access to install packages.
  • A domain name or IP address pointing to your server (optional but recommended).
  • At least 2 GB of RAM and 10 GB free disk space (more if you have many photos).
  • Basic familiarity with the command line.

Step-by-Step

  1. Update your system
    Open a terminal and run:
    sudo apt update && sudo apt upgrade -y
  2. Install required packages
    Lychee needs Nginx, PHP, and MySQL. Run:
    sudo apt install nginx mysql-server php-fpm php-mysql php-xml php-mbstring php-curl php-zip php-gd php-bcmath -y
    The exact PHP extensions may vary by version; if you see a missing one later, install it with sudo apt install php-<extension>.
  3. Secure MySQL and create a database
    Run sudo mysql_secure_installation and follow the prompts (set a root password, remove anonymous users, etc.). Then log into MySQL:
    sudo mysql -u root -p
    Create a database and user (replace lychee_user and strong_password):
    CREATE DATABASE lychee;
    CREATE USER 'lychee_user'@'localhost' IDENTIFIED BY 'strong_password';
    GRANT ALL PRIVILEGES ON lychee.* TO 'lychee_user'@'localhost';
    FLUSH PRIVILEGES;
    EXIT;
  4. Download Lychee
    Go to the official Lychee GitHub releases page and grab the latest version (e.g., lychee-v5.0.0.zip). Then:
    cd /var/www
    sudo wget https://github.com/LycheeOrg/Lychee/releases/download/v5.0.0/lychee-v5.0.0.zip
    sudo unzip lychee-v5.0.0.zip -d lychee
    sudo chown -R www-data:www-data /var/www/lychee
    If unzip is not installed, run sudo apt install unzip first.
  5. Configure Nginx
    Create a new Nginx site configuration:
    sudo nano /etc/nginx/sites-available/lychee
    Paste the following (adjust server_name to your domain or IP):
    server {
        listen 80;
        server_name example.com;
        root /var/www/lychee/public;
        index index.php;
    
        location / {
            try_files $uri $uri/ /index.php?$query_string;
        }
    
        location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
        }
    
        location ~ /\.ht {
            deny all;
        }
    }
    The PHP socket path may differ (e.g., php8.2-fpm.sock). Check with ls /var/run/php/. Enable the site and restart Nginx:
    sudo ln -s /etc/nginx/sites-available/lychee /etc/nginx/sites-enabled/
    sudo nginx -t
    sudo systemctl restart nginx
  6. Run the Lychee installer
    Open your browser and go to http://your-server-ip. You'll see the Lychee setup page. Fill in:
    • Database host: localhost
    • Database port: 3306
    • Database name: lychee
    • Username: lychee_user
    • Password: the one you set
    Click “Install” and follow the prompts to create your admin account.
  7. Set up storage and permissions
    Lychee stores photos in /var/www/lychee/storage. Ensure the web server can write there:
    sudo chown -R www-data:www-data /var/www/lychee/storage
    sudo chmod -R 755 /var/www/lychee/storage
  8. Enable HTTPS (recommended)
    Install Certbot for free SSL:
    sudo apt install certbot python3-certbot-nginx -y
    sudo certbot --nginx -d example.com
    Follow the prompts. This gives you a secure connection.

Common Mistakes

  • Wrong PHP socket path — If you see “502 Bad Gateway,” the fastcgi_pass path is wrong. Fix it in the Nginx config.
  • Missing PHP extensions — Lychee may complain about missing modules. Install them with sudo apt install php-<extension> and restart PHP-FPM.
  • File permission errors — If uploads fail, check that the storage folder is owned by www-data.
  • Using the wrong database credentials — Double-check the username and password; MySQL is case-sensitive.
  • Forgetting to enable the Nginx site — If you get the default Nginx page, you didn't symlink the config or restart Nginx.

Tips

  • Back up your /var/www/lychee folder and the MySQL database regularly. Use a cron job to dump the database.
  • Use a dedicated subdomain like photos.example.com to keep things clean.
  • Enable two-factor authentication in Lychee settings for extra security.
  • If you have a large photo library, consider using an external storage drive and mounting it to /var/www/lychee/storage.
  • Keep Lychee updated by checking the GitHub releases page and following the upgrade instructions.

Troubleshooting

  1. Check Nginx error logs — Run sudo tail -f /var/log/nginx/error.log to see what's failing.
  2. Verify PHP-FPM is running — sudo systemctl status php8.1-fpm (adjust version). If not, start it with sudo systemctl start php8.1-fpm.
  3. Test the database connection — From the command line, run mysql -u lychee_user -p to ensure credentials work.
  4. If the installer hangs — Check the browser console for errors and ensure all PHP extensions are installed.
  5. If you get a 403 error — Check file permissions: sudo chmod -R 755 /var/www/lychee and ensure the root path in Nginx points to /public.
  6. If photos don't upload — Check the PHP upload_max_filesize and post_max_size in /etc/php/8.1/fpm/php.ini. Increase them (e.g., to 100M) and restart PHP-FPM.

Frequently Asked Questions

Can I use SQLite instead of MySQL?

Yes, Lychee supports SQLite, but MySQL/MariaDB is recommended for larger libraries and better performance. If you use SQLite, skip the database creation step and choose SQLite during installation.

How do I update Lychee to a new version?

Back up your data, then download the new release, extract it over the old files (keeping the .env file and storage folder), and run any upgrade scripts mentioned in the release notes. Usually, you just refresh the browser.

Can I access Lychee from outside my home network?

Yes, but you should use HTTPS and consider a VPN or reverse proxy for security. Exposing it directly to the internet without protection is risky.

Does Lychee support face recognition?

No, Lychee does not have built-in face recognition. It focuses on albums, tags, and metadata. For face recognition, consider other tools like PhotoPrism.

Can I import photos from my phone?

Yes, you can upload through the web interface, or use the Lychee mobile app (if available) or third-party tools that sync to the Lychee API.

What if I forget my admin password?

You can reset it by running a command in the Lychee directory using php artisan lychee:reset-admin, which will create a new admin user.