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://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
[user]$ sudo add-apt-repository 'deb http://ftp.osuosl.org/pub/mariadb/repo/10.0/ubuntu 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)]> FLUSH PRIVILEGES;
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 ~/yourLycheeSite.com/{public_html,logs}
[user]$ git clone https://github.com/electerious/Lychee.git ~/yourLycheeSite.com/public_html

PHP-FPM configuration

Create a new PHP-FPM pool for your user:

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

Restart PHP-FPM:

[user]$ sudo service php5-fpm restart

Nginx configuration

Create a new Nginx server block with the following content:

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS
[user]$ cat << EOF | sudo tee /etc/nginx/sites-available/yourLycheeSite.com
server {
    server_name yourLycheeSite.com;
    listen 80;
    root $HOME/yourLycheeSite.com/public_html;

    access_log $HOME/yourLycheeSite.com/logs/access.log;
    error_log $HOME/yourLycheeSite.com/logs/error.log;

    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;
    }    
}
EOF

Activate the server block by creating a symbolic link :

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

Test the Nginx configuration and restart nginx:

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

Final steps

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

Clipboard02

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

Clipboard022

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.

5 thoughts on “Install Lychee on an Ubuntu VPS”

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

    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.

      Reply
  2. I woud not expose this on the open net like this. Anyone can access the data directory, and thus get your config.php which contains db credentials, logged in or not.

    Reply

Leave a Comment