# Install Lychee - Photo Management System - On Linux

## What is Lychee?

> Lychee is a free photo-management tool, which runs on your server or web-space. Installing is a matter of seconds. Upload, manage and share photos like from a native application. Lychee comes with everything you need and all your photos are stored securely. -https://lycheeorg.github.io/

## Installation

1. Log into the Linux device
2. Run the following commands in a terminal window:
   # update software repositories
   sudo apt update
   # install available software updates
   sudo apt upgrade -y
   # install prerequisites
   sudo apt install curl wget zip -y
   # install Apache HTTPD and MySQL
   sudo apt install apache2 mariadb-server mariadb-client -y
   # install PHP components
   sudo apt install php php-common php-mysqli php-mysql php-pdo-mysql php-bcmath php-gd php-xsl php-mbstring php-dom php-imagick php-xml -y
   # configure the MySQL database
   sudo su
   mysql_secure_installation
3. Press Enter to login as root
4. Type N and press Enter to not switch to unix socket authentication
5. Type Y and press Enter to set a root password, type the password twice to confirm
6. Type Y and press Enter to remove anonymous users
7. Type Y and press Enter to disallow root login remotely
8. Type Y and press Enter to remove the test database
9. Type Y and press Enter to reload privilege tables
10. Run the following command to login into MySQL:
    mysql -u root -p
11. Authenticate with the root password set earlier
12. Run the following commands to create the Lychee database and database user
    CREATE DATABASE lychee;
    GRANT ALL ON lychee.* to 'lychee_rw'@'localhost' IDENTIFIED BY 'Lych33!';
    FLUSH PRIVILEGES;
    EXIT;
    exit
13. Continue with the following commands:
    # fetch the latest download URL
    regex='"browser_download_url": "(https:\/\/github.com\/LycheeOrg\/Lychee\/releases\/download\/[^/]*\/[^/]*\.zip)"' && response=$(curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/LycheeOrg/Lychee/releases/latest) && [[ $response =~ $regex ]] && downloadURL="${BASH_REMATCH[1]}"
    # download the latest release
    wget -O /tmp/lychee.zip $downloadURL
    # extract the downloaded zip to /var/www
    sudo unzip /tmp/lychee.zip -d /var/www
    # rename the extracted folder
    sudo mv /var/www/Lychee* /var/www/lychee
    # set the owner of the lychee directory
    sudo chown -R www-data:www-data /var/www/lychee
    # create lychee apache configuration
    sudo nano /etc/apache2/sites-available/lychee.conf
14. Paste the following configuration into lychee.conf

    Alias /lychee "/var/www/lychee/public"
    <Directory /var/www/lychee/public>
    # enable the .htaccess rewrites
    AllowOverride All
    Order allow,deny
    Allow from All
    </Directory>

15. Press CTRL+O, Enter, CTRL+X to write the changes
16. Run the following command to enable the lychee site
    # enable rewrite module
    sudo a2enmod rewrite
    # enable the lychee site
    sudo a2ensite lychee
    # restart the apache2 service
    sudo systemctl restart apache2

## Lychee Web Installer

1. Open a web browser and navigate to http://DNSorIP/lychee
2. Click Next at the Lychee welcome screen
3. Click Next at the Requirements Check
4. Click Next at the Permissions Check
5. Update at least the following values in the

   APP_URL=http://DNSorIP
   APP_DIR=/lychee
   DB_CONNECTION=mysql
   DB_HOST=localhost
   DB_PORT=3306
   DB_DATABASE=lychee
   DB_USERNAME=lychee_rw
   DB_PASSWORD=Lych33!

6. Click Save > Click Install
7. Once the installation completes click Set up admin account
8. Enter a Username > Enter and confirm a Password > Click Create admin account
9. Click Open Lychee
10. Welcome to Lychee

Documentation: https://lycheeorg.github.io/docs/#installation