Build Free Image Host on Your Own Server

I am using hexo to write my blog, but some of the images in my blog are large and they could take up large space. Therefore, using the Asset Folders to host images is not suitable if we also maintain the source files on github. Although there are some websites providing image hosting service, they either need to pay or would add watermarkers. As I deploy my blog on a cloud server rent in Digital Ocean, I decided to build my own image host.

I have tried many methods but not all of them worked and many of them lacks tutorials, so I wrote this article here to record it. I finally used Lychee on my Ubuntu 16.04 server.

Demo

Requirements

  • LAMP. I installed php5.6 and current version is 7, so the version number is needed, e.g., install php5-cli instead.
  • phpMyAdmin (optional, as the database can also be operated in command lines)
  • Modify php.ini to enable large files to be uploaded. In my case, the file is located in /etc/php/5.6/apache/php.ini. Note that there might be more than one php.ini, be sure to find the correct one. Increase the values as:

    1
    2
    3
    4
    max_execution_time = 200
    post_max_size = 100M
    upload_max_size = 100M
    memory_limit = 256M
  • Install the php extensions: session, exif, mbstring, gd, mysqli, json, zip.

Installation

  • Download Lychee with git (assume that current location is home).

    1
    git clone https://github.com/electerious/Lychee.git
  • Copy the directory to /var/www/. I chose rsync command. Be sure to use Lychee not Lychee/.

    1
    rsync -avP Lychee /var/www/

Permissions

Change the owner of the folder to apache user (the default if www-data).

1
chown -R www-data:www-data /var/www/Lychee

Finish

Some Unsuccessful Tests

Chevereto

This is an open-source script and the developers also provide documentation. There is also a tutorial, but some configuration is not friendly to beginners and I had troubles.

  • The SELECT FILES button wouldn’t appear in Chrome.
  • After uploading selected images, the generated link is invalid. I didn’t find any related configuration so I finally abandoned it.
FileZ

It can share large files with unique URLs. But it was last updated 5 years ago and some of the links in the documentation are invalid. My issue is that even I have motified all the parameters as instruction, the crucial file config/filez.ini wouldn’t be generated.

Piwigo

It’s an open-source gallery application. There’s also detailed documentation on github and a good tutorial. However, Piwigo can only upload and display photos but cannot share the uploaded images with links.

Share