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
4max_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 chosersync
command. Be sure to useLychee
notLychee/
.1
rsync -avP Lychee /var/www/
Permissions
Change the owner of the folder to apache user (the default is www-data
).1
chown -R www-data:www-data /var/www/Lychee
Finish
- Open the Lychee through browser (usually http://yoursite/Lychee).
- Follow the steps.
- Enjoy!
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.