How to Install LibrePhotos on Debian Latest

LibrePhotos is a self-hosted photo management solution. With LibrePhotos, you can easily organize and manage your photos, view them in a slideshow, and share them with your friends and family. In this tutorial, we will guide you through the process of installing LibrePhotos on Debian Latest.

Prerequisites

Before we start with the installation process, make sure that you have the following requirements:

Step 1: Update the System

The first step is to ensure that your Debian system is up-to-date. Run the following command to update the system:

sudo apt update && sudo apt upgrade

Step 2: Install Required Packages

Next, install the required packages for LibrePhotos:

sudo apt install python3-pip python3-dev libpq-dev postgresql postgresql-contrib nginx

During the installation, you will be asked to set a password for the PostgreSQL server.

Step 3: Create a Database

After installing the packages, log in to the PostgreSQL server:

sudo -u postgres psql

Create a new database and user for LibrePhotos:

CREATE DATABASE librephotos;
CREATE USER librephotos WITH PASSWORD 'password';
GRANT ALL PRIVILEGES ON DATABASE librephotos TO librephotos;

Replace 'password' with a secure password for the database user.

Exit the PostgreSQL server:

\q

Step 4: Install LibrePhotos

Clone the latest version of LibrePhotos from its GitHub repository:

git clone https://github.com/LibrePhotos/librephotos.git

Change the directory to the project:

cd librephotos

Install the required Python packages:

pip3 install -r requirements.txt

Step 5: Configure the Application

Create a configuration file for the application:

cp .env.sample .env

Edit the .env file and update the following parameters:

Step 6: Migrate the Database

Migrate the database schema using Django's manage.py script:

python3 manage.py migrate

Step 7: Create a Superuser

Create a Django superuser to manage the application:

python3 manage.py createsuperuser

Enter the required information, such as username, email, and password.

Step 8: Collect Static Files

Collect the static files required by the application:

python3 manage.py collectstatic --noinput

Step 9: Configure NGINX

Create a new NGINX Server Block file:

sudo nano /etc/nginx/sites-available/librephotos

Paste the following configuration:

server {
    listen      80;
    server_name example.com www.example.com;
    return      301 https://$server_name$request_uri;
}

server {
    listen 443 ssl;
    server_name example.com www.example.com;

    ssl_certificate /path/to/fullchain.pem;
    ssl_certificate_key /path/to/privkey.pem;
    ssl_session_timeout 5m;   
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers on;
    ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA512:DHE-RSA-AES128-GCM-SHA256;

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

Replace example.com and www.example.com with your domain or subdomain name. Also, replace /path/to/fullchain.pem and /path/to/privkey.pem with the paths to your SSL certificate and key files.

Create a symbolic link to the sites-enabled directory:

sudo ln -s /etc/nginx/sites-available/librephotos /etc/nginx/sites-enabled/

Test the NGINX configuration:

sudo nginx -t

If the configuration is valid, restart NGINX:

sudo systemctl restart nginx

Step 10: Run the Application

Start the Django development server:

python3 manage.py runserver 127.0.0.1:8000

Open your web browser and visit https://example.com/admin/ (replace example.com with your domain or subdomain name). Log in to the application with the Django superuser credentials created earlier.

Congratulations! You have successfully installed and configured LibrePhotos on Debian Latest. Now you can start uploading your photos and organizing them with this self-hosted photo management solution.

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!