Install Lychee on an Ubuntu VPS

install-lychee-on-an-ubuntu-vpsIn this tutorial, we will explain how to install Lychee on an Ubuntu 14.04 VPS with MariaDB, PHP-FPM and Nginx. Lychee is an easy-to-use self hosted photo management system. This guide should work on other Linux VPS systems as well but was tested and written for an Ubuntu 14.04 VPS.

Login to your VPS via SSH

ssh user@vps

Update the system and install necessary packages

[user]$ sudo apt-get update && sudo apt-get -y upgrade
[user]$ sudo apt-get install software-properties-common git

Install MariaDB 10.0

[user]$ sudo apt-key adv --recv-keys --keyserver hkp:// 0xcbcb082a1bb943db
[user]$ sudo add-apt-repository 'deb trusty main'
[user]$ sudo apt-get update
[user]$ sudo apt-get install mariadb-server

When the installation is complete, run the following command to secure your installation:

[user]$ mysql_secure_installation

Next, we need to create a database for our Lychee installation.

[user]$ mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE lychee;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON lychee.* TO 'lycheeuser'@'localhost' IDENTIFIED BY 'lycheeuser_passwd';
MariaDB [(none)]> \q

Install PHP-FPM and Nginx

Installing PHP and Nginx is pretty easy, just run the following command to install Nginx PHP FPM and all necessary PHP modules:

[user]$ sudo apt-get install nginx php5-fpm php5-cli php5-gd php5-mysqlnd php5-curl php5-json

Open the ‘/etc/php5/fpm/php.ini’ file and set the following values:

max_execution_time = 200
post_max_size = 100M
upload_max_size = 100M
upload_max_filesize = 20M
memory_limit = 256M

Install lychee

Create a root directory for your web site and clone the git repository from github using the following commands:

[user]$ mkdir -p ~/{public_html,logs}
[user]$ git clone ~/

PHP-FPM configuration

Create a new PHP-FPM pool for your user:

[user]$ cat << EOF | sudo tee /etc/php5/fpm/pool.d/$(whoami).conf
user = $(whoami)  
group = $(whoami)  
listen = /var/run/php5-fpm-$(whoami).sock  
listen.owner = $(whoami) = $(whoami)  
listen.mode = 0666  
pm = ondemand  
pm.max_children = 5  
pm.process_idle_timeout = 10s;  
pm.max_requests = 200  
chdir = /

Restart PHP-FPM:

[user]$ sudo service php5-fpm restart

Nginx configuration

Create a new Nginx server block with the following content:

[user]$ cat << EOF | sudo tee /etc/nginx/sites-available/
server {
    listen 80;
    root $HOME/;

    access_log $HOME/;
    error_log $HOME/;

    index index.php;

    location / {
        try_files \$uri \$uri/ /index.php?\$query_string;
    location ~* \.(?:ico|css|js|gif|jpe?g|png|ttf|woff)\$ {
        access_log off;
        expires 30d;
        add_header Pragma public;
        add_header Cache-Control "public, mustrevalidate, proxy-revalidate";

    location ~ \.php\$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)\$;
        fastcgi_pass unix:/var/run/php5-fpm-$(whoami).sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;

    location ~ /\.ht {
        deny all;

Activate the server block by creating a symbolic link :

[user]$ sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/

Test the Nginx configuration and restart nginx:

[user]$ sudo nginx -t
[user]$ sudo service nginx restart

Final steps

Open in your favorite web browser and you should see the Lychee install screen. Provide the database information and click on the “Connect” button:


On the next screen you will be asked to create a new user:


That’s it. You have successfully installed Lychee on your Ubuntu 14.04 VPS. For more information about how to manage your Lychee installation, please refer to the Lychee website.

Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to setup this for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Install Squid on Debian 6 ‘Squeeze’
How to install Traq on an Ubuntu 16.04 VPS
How to install Varnish and phpMyAdmin on a CentOS 7 VPS with Nginx, MariaDB and PHP-FPM
  • juani


    Author Reply

    Does lychee really needs mariadb10?
    I have other web applications running on my server, who knows if they will work with version 10!

    • admin


      Author Reply

      Hey Juani. If MariaDB doesn’t work for you, then use MySQL. Everything you need for Lychee is a web-server with PHP 5.3 or later and a MySQL-Database.

  • p


    Author Reply

    Nice tutorial,

    however you missed a “apt-get update” after adding the mariaDB 10 repo. Without an update MariaDB 5 will be installed!

    • admin


      Author Reply

      Thank you for noticing this. It has been fixed.