How to Set Up Your Own Linux Photo Management System with Lychee

Ever wanted to access your photos from anywhere via the Web but didn’t want to sign up for proprietary solutions like Google Photos, Photo Bucket, etc.? Introducing Lychee, a self-hosted tool that allows users to manage, upload and catalog their large photo collections. It runs on any web server that has Apache2 (or NGINX), PHP and MySQL.

In this tutorial we’ll be using the Ubuntu server. This is not to say that Lychee will not run on other Linux server operating systems. The instructions are essentially the same, minus a few package changes. Just make sure you have MySQL, the latest PHP and Apache2 (or Nginx).

Hardware Requirements

  • a Linux server distribution that has the ability to run and install snapd
  • any moderately-powerful old desktop PC (DDR-2 era or better) that can stay on at all times and act as a server
  • a VPS or any other type of enterprise-grade server

Installing Ubuntu Server

Go to Ubuntu’s website and download the latest version of Ubuntu Server. After downloading it, make a live installation tool with Etcher. Follow the instructions on the website. Using it is a three-step process. Alternatively, burn the Ubuntu disc image to a DVD or CD.

lychee-ubuntu-server-download

Using the BIOS on the server, change the boot order so that the Ubuntu Server installation medium loads first. Keep in mind that the BIOS button is different (some are DEL, F2 or ESC) on every machine, so refer to your manual to be sure of the correct button.

The Ubuntu Server installation disk is loaded. As a result, a selection menu appears with several options. Select “Install Ubuntu Server” to move onto the installation.

lychee-ubuntu-server-boot-menu

On the next page Ubuntu server asks the user to select the correct language. Using the arrow keys, find your language, then press Enter.

lychee-select-language-ubuntu-server

Next, set a hostname for Ubuntu server. Name it “ubuntu-lychee,” “ubuntu-server,” “ubuntu,” or something similar. This is mainly to identify the device on the network from other computers.

lychee-set-ubuntu-server-hostname

Add a username to the server as well as a memorable, secure password.

lychee-ubuntu-server-partition-layout-guided

After setting the username, Ubuntu server brings up the partition manager. Using the arrow keys, select “guided – use entire disk” and press the Enter key. This will allow Ubuntu Server to automatically partition everything.

lychee-ubuntu-server-select-packages

After the base-installation, Ubuntu server prompts the user to select packages to install. Using the arrow keys to hover over an option, press the spacebar to select. Select LAMP server, standard system utilities and OpenSSH server. Then, wait for the installation to complete. When the installation is finished, restart the machine.

Note: installing the LAMP server package will prompt you to add a MySQL root password. Enter a secure, memorable one as it will come in handy later.

Installing Lychee

First, log into MySQL with the root password set up earlier.

mysql -u root -p

This will give you root access in MySQL. Now create the Lychee database.

create database lychee;

Then, change the permissions on the database; add a database user and password.

GRANT ALL PRIVILEGES ON lychee. * TO lycheeuser@'localhost' IDENTIFIED BY 'ReplaceWithPasswordHere' WITH GRANT OPTION;

Lastly, flush the privileges, and exit MySQL.

flush privileges;
quit

Create an Apache2 configuration file.

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

Paste the following:

VirtualHost *:80>
ServerAdmin admin@domainnamehere.com
DocumentRoot /var/www/html/Lychee/
ServerName your-domain.com
ServerAlias www.domainnamehere.com
<Directory /var/www/html/Lychee/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/domainname.com-error_log
CustomLog /var/log/apache2/domainname.com-access_log common
</VirtualHost>

Then save by pressing “Ctrl + O” on the keyboard. Restart apache2.

sudo service apache2 restart

Install git, some PHP addons and grab the Lychee code.

sudo apt install git php-cli php-gd php-mysqlnd php-curl php-json php-zip php-exif php-session php-mbstring

Once the installation is done, go to the Apache web folder:

cd /var/www/html/

Grab the Lychee code:

sudo git clone https://github.com/electerious/Lychee.git

Lastly, change the permissions.

cd Lychee
sudo chmod -R 777 uploads/ data/

Setting Up Lychee

Use ifconfig to find the local IP address, then enter the IP address into a web browser to access Lychee (something like http://local.ip.address/Lychee).

When the Lychee web interface loads, it asks you to specify the SQL database, user and password.

  • For user: lycheeuser
  • For database: lychee
  • For password: enter the password that was set during the database creation process.

After filling out the information needed, you’ll need to create a login. Enter a username and secure password, then click “Create.”

Using Lychee

lychee-photos

Adding photos to your Lychee server is easy! Upload a folder by clicking the “+” sign, then clicking the “Upload” button. From here, browse for your photo and upload it. You should see your new photo in the “unsorted” album instantly.

Create Album

lychee-create-new-album

Create a new photo album by clicking the “+” icon, then clicking “Create Album.” To upload to any album, select it in Lychee, then go to the “+” sign and click the “Upload” button.

Import Via Link

lychee-upload-via-url

Lychee supports uploading via the Web. Find a direct link to any image on the Internet, then click the “+” icon and “Import via Link” to upload the image directly to your photo library.

Other Ways to Import

Besides uploading via Link, Lychee also supports other ways to import. To import a massive amount of photos at once, click “Import via server,” then place the photos in a folder on the server, specify it’s location and click the Import button.

lychee-dropbox

It is also possible to upload via Dropbox. Click the gear icon in the top-left corner, then select “Setup Dropbox.” Follow the onscreen instructions to link Dropbox. When linked, click the “+” sign to import photos into the Lychee library via Drobox.

Conclusion

Online photo management has gotten better in the last few years, but there really hasn’t been many good self-hosted, easy-to-use alternatives Linux users can use – until now. That’s why I’m glad Lychee is around, as it makes it easy for anyone to set up their own online photo system that rivals something that Google or Microsoft would come up with.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Derrik Diener

Derrik Diener is a freelance technology blogger.