LowEndBox

Hosting Websites on Bare Minimum VPS/Dedicated Servers

How to Self Host Images and Photos with Ubuntu VPS

Tags: , , Date/Time: December 1, 2016 @ 4:09 am, by Jon Biloh

lowendtutorial

Hobbyists who look to have maximum control over the image files that they host online may look into purchasing a virtual private server. If you are looking for an alternative to Flickr, a VPS could be the perfect alternative.

Several applications exist that will help you self-host your own images. Some are more basic than others; for example, you may wish to have the ability to mark photos as private or password protect specific areas of the site.

In this article, we’ll detail the command line installation instructions of Lychee, an open source app that is used for hosting images on virtual private servers. These install instructions will help you install Lychee on an Ubuntu 16.04 server. Use commands with sudo when needed.

Prerequisites:

Run updates:

> sudo apt-get update

Install LAMP
Go ahead and install Apache, PHP and MySQL using these commands:

> sudo apt-get install apache2
> sudo apt-get install php

> sudo apt-get install mysql-server

> sudo apt install php libapache2-mod-php

If you are asked to create a username and password for MySQL, make a note of this as you’ll need it later.

To configure Lychee, we need make sure that the following list of extensions is enabled in our PHP build:

  • session
  • exif
  • mbstring
  • gd
  • mysqli
  • json
  • zip

To see what extensions are pre-enabled on your box, type this command:

> sudo php –m

In my test, my VPS was missing mbstring, gd, mysqli and zip. Let’s get these enabled.

I ran:

sudo apt-get install php-cli php-gd php-mysqlnd php-curl php-json php-zip php-mbstring

For good measure, let’s restart apache.

> sudo service apache2 restart

Let’s confirm that the extensions are enabled

> sudo php –m

According to my output, all of the prerequisites now seem to be installed. If you are missing some of the other prerequisites, you might have to do some Googling to get the exact command you need.
Now we must adjust the PHP.ini file in order for Lychee to work properly. Use the following command:

> nano /etc/php/7.0/apache2/php.ini

You’ll want to find the following lines and change it to these settings:

max_execution_time = 200

post_max_size = 100M

upload_max_size = 100M

upload_max_filesize = 20M

memory_limit = 256M

Hint, you’ll be able to use CTRL+W to find these terms in Nano editor. You’ll simply find these values and change them and save the PHP.ini file.

Hit CTRL+O to save and select yes. You’ll want to hit CTRL+X to exit. It’s a good idea to reload Apache using the command we used previously to do so.

From here, we can clone the Lychee files onto the VPS. Use the following sequence of commands:

> cd /var/www/html

> git clone https://github.com/electerious/Lychee.git

> chown -R www-data:www-data /var/www/html/Lychee

Then change the permissions of the upload directory.

> cd Lychee

> sudo chmod -R 777 uploads/ data/

From here, let’s restart Apache one more time.

> sudo service apache2 restart

Congrats, you’ve installed Lychee. Let’s login to the app to continue configuring your new photo sharing application self-hosted on your VPS.

In your browser, go to http://<IPADDRESS>/Lychee

You’ll be asked for a server name, database username, database password and database name. If you’ve followed these instructions, you should simply enter in the database username and password that you created in a previous step and leave the rest of the fields blank.

Once this is complete, you’ll be able to create an administrative username and password for the Lychee app.

Now that the application setup is complete, you can begin uploading your photos onto your privately administrated virtual private server. For more information about Lychee, visit the project’s page on GitHub.

4 Comments

  1. Adduc:

    Are technical terms getting blocked in the comments? I’m trying to reply and am getting CloudFlare’s blocked notification.

    December 1, 2016 @ 5:02 am | Reply
  2. Good tutorial!

    December 2, 2016 @ 9:38 pm | Reply
  3. josh:
    December 5, 2016 @ 7:52 pm | Reply
  4. Sven:

    It’s bad security practise to change the ownership of script pages to www-data.
    Only the upload directory and the non-executable files should be owned by www-data.

    December 7, 2016 @ 12:42 pm | Reply

Leave a Reply

Some notes on commenting on LowEndBox:

  • Do not use LowEndBox for support issues. Go to your hosting provider and issue a ticket there. Coming here saying "my VPS is down, what do I do?!" will only have your comments removed.
  • Akismet is used for spam detection. Quoting webhostingtalk.com URL seems to get binned consistently here, but I do peek into the spam box frequently to publish those comments.
  • Use <pre>...</pre> to quote the output from your terminal/console, or consider using a pastebin service.

Your email address will not be published. Required fields are marked *