How to Install LibrePhotos on Ubuntu Server

LibrePhotos is a self-hosted alternative to Google Photos or Apple Photos. It allows you to store, organize, and share your photos securely on your server. In this tutorial, we will guide you on how to install LibrePhotos on Ubuntu Server latest version.

Prerequisites

Before we proceed with the installation of LibrePhotos, you must have:

Install Required Dependencies

First, we need to install some required packages to set up the environment for LibrePhotos. Run the following command to update the package list:

sudo apt update

After that, we can install the required packages by running the following command:

sudo apt install python3-pip python3-dev libjpeg-dev zlib1g-dev libpython3-dev build-essential libssl-dev libffi-dev libpq-dev

Install and Configure PostgreSQL

LibrePhotos provides support for both MySQL and PostgreSQL databases. In this tutorial, we will use PostgreSQL because it is a robust and reliable database server. If you already have a PostgreSQL server up and running, you can skip this step.

To install PostgreSQL, run the following command:

sudo apt install postgresql

Then, create a new user and database for LibrePhotos by running the following commands:

sudo -u postgres createuser -P librephotos
sudo -u postgres createdb -O librephotos librephotos_db

It will prompt you to enter the password for the new user. Enter a strong password and remember it because we will use it later.

After that, we need to modify the PostgreSQL configuration file to allow the new user to connect to the database. Open the file /etc/postgresql/<version>/main/pg_hba.conf with your favorite text editor and add the following line at the end of the file:

host    librephotos    librephotos    127.0.0.1/32    md5

Where <version> is the version number of your PostgreSQL installation, for example, 12.

Save and close the file. Then, restart the PostgreSQL server to apply the changes:

sudo systemctl restart postgresql

Install and Configure LibrePhotos

Now we are ready to install and configure LibrePhotos. Follow these steps:

  1. Install LibrePhotos using pip by running the following command:

    sudo pip3 install librephotos
    
  2. Create a new configuration file for LibrePhotos by running the command:

    librephotos init
    

    It will prompt you for the location to store the configuration file. Press Enter to accept the default value, which is /etc/librephotos/config.py.

  3. Edit the configuration file with your favorite text editor, and modify the following parameters:

    DATABASE_URL = 'postgresql://librephotos:<your_password>@localhost/librephotos_db'
    ALLOWED_HOSTS = ['your_server_ip_address', 'your_domain_name']
    

    Replace <your_password> with the password you set for the postgresql user earlier. Replace your_server_ip_address and your_domain_name with the IP address or domain name of your server.

  4. Create a new secret key for LibrePhotos by running the command:

    librephotos generate-secret
    
  5. Finally, run the following command to set up the database and start the web server:

    librephotos setup 
    

    This will create the necessary tables in the database, and launch the web server on port 8000.

You can now access your LibrePhotos server by opening your web browser and entering the following address:

http://your_server_ip_address:8000

Or if you set up the ALLOWED_HOSTS with your domain name:

http://your_domain_name:8000

Conclusion

In this tutorial, we have shown you how to install and configure LibrePhotos on Ubuntu Server. You can now enjoy a self-hosted alternative to Google Photos, where you have full control over your data and privacy.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!