How to Self-Host Lychee on a VPS (Complete Guide)
Lychee is a popular open-source photo management tool that offers a beautiful interface to manage your images. Hosting Lychee on a Virtual Private Server (VPS) is an excellent way to maintain complete control of your photo library. In this guide, we will walk you through the steps of self-hosting Lychee on a VPS, listing essential requirements, installation, and configurations for smooth operation.
Why Use a VPS for Lychee?
Using a VPS for self-hosting Lychee comes with myriad benefits:
- Control: You have full control over server settings and configurations.
- Performance: VPS resources are dedicated, which means better performance compared to shared hosting.
- Cost-effective: Affordable plans are available without sacrificing quality.
Recommended VPS Providers
Before installing Lychee, select a VPS provider based on your needs:
| Provider | Price | Features |
|---|---|---|
| Contabo VPS | 5.99 EUR/mo | Disk space options, reliable support |
| Hetzner Cloud | 4.15 EUR/mo | High performance, scalable solutions |
| DigitalOcean | 6 USD/mo | Simple API, one-click apps |
| Vultr | 6 USD/mo | Wide range of locations, flexible |
| Linode (Akamai Cloud) | 5 USD/mo | High IOPS SSD storage |
Find more details in our full VPS comparison.
Prerequisites
- VPS Instance: Any of the providers listed above will work. For this guide, weโll assume you are using a simple Linux-based instance (e.g., Ubuntu 20.04).
- Root Access: Ensure that you have root or sudo privileges to install the necessary packages.
- Domain Name (optional): If you want to access Lychee via a domain name, registering one is recommended.
Installing Lychee on a VPS
Step 1: Initial Server Setup
-
Update the Server:
sudo apt update && sudo apt upgrade -y -
Install Necessary Packages: Install Nginx, PHP, and MariaDB:
sudo apt install nginx php-fpm php-mysql php-xml php-gd php-curl php-zip mariadb-server -y -
Start and Enable Services: Make sure Nginx and MariaDB run on system startup:
sudo systemctl start nginx sudo systemctl enable nginx sudo systemctl start mariadb sudo systemctl enable mariadb
Step 2: Configure the Database
-
Secure MariaDB:
sudo mysql_secure_installation -
Create Database and User: Log into MariaDB:
sudo mysql -u root -pThen execute the following SQL commands:
CREATE DATABASE lychee; CREATE USER 'lycheeuser'@'localhost' IDENTIFIED BY 'your_password'; GRANT ALL PRIVILEGES ON lychee.* TO 'lycheeuser'@'localhost'; FLUSH PRIVILEGES; EXIT;
Step 3: Download and Install Lychee
-
Get Lychee Code:
cd /var/www sudo git clone https://github.com/LycheeOrg/Lychee.git -
Set Permissions:
sudo chown -R www-data:www-data /var/www/Lychee sudo chmod -R 755 /var/www/Lychee -
Configure Nginx: Create a new server block for Lychee:
sudo nano /etc/nginx/sites-available/lycheeAdd the following configuration:
server { listen 80; server_name your_domain.com; # Replace with your domain root /var/www/Lychee; index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # Adjust according PHP version fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } -
Enable Configuration:
sudo ln -s /etc/nginx/sites-available/lychee /etc/nginx/sites-enabled/ sudo nginx -t sudo systemctl reload nginx
Step 4: Finalizing Lychee Installation
-
Access Lychee: Go to
http://your_domain.com(adjust with your actual domain). Follow the setup instructions and enter the database credentials created earlier. -
Configure Environment Settings: Edit the
.envfile in the Lychee directory for additional configurations, ensuring it points to your database.
Optional: Installing Lychee via Docker
For those who prefer using Docker, Lychee can also be installed with Docker:
docker run -d -p 80:80 -v /path/to/storage:/var/www/lychee/uploads lychee/lychee
FAQs
1. Can I run Lychee on low-cost VPS options?
Yes, most low-cost VPS options, such as Hetzner Cloud at 4.15 EUR/mo, provide enough resources to run Lychee efficiently. As a lightweight application, Lychee doesnโt require a significant amount of memory or CPU, making it a suitable choice for smaller VPS instances.
2. How do I secure my Lychee installation?
To secure your Lychee installation, consider enabling HTTPS using Letโs Encrypt. Additionally, set up a strong password for your database user and regularly update both your server and Lychee application to mitigate vulnerabilities. Firewalls like UFW can also enhance security by limiting access to essential ports only.
3. What should I do if I experience issues with performance?
If you encounter performance issues, first check your server resource usage via tools like top or htop to monitor CPU and memory. Upgrading your VPS plan or optimizing database queries could help. Review Lycheeโs logs as well, as they might provide insights on any bottlenecks or errors affecting performance.
Now you are equipped to self-host Lychee on your chosen VPS! Whether you opt for Docker or traditional installation, you can enjoy managing your photo library with confidence. Happy hosting!