# How to set up a remote picture library with LibrePhotos and Meshnet

## Introduction <a href="#introduction" id="introduction"></a>

Having your own easily accessible picture library can prove to be beneficial when you want to share pictures with your friends or family. Instead of sending files one by one and waiting for the transfers to finish, you can provide them with a link to see the latest images of your pets or a recent trip to the mountains.

While there are cloud-based solutions that offer similar functionality, self-hosting your image library puts you in full control, and you don’t need to worry about pricing or cloud storage restrictions. Additionally, the files never have to leave your device.

By using self-hosted picture management tools, such as the open-source [LibrePhotos](https://docs.librephotos.com/docs/intro) project, alongside [Meshnet](https://nordvpn.com/meshnet/), you can set up a secure, [remotely accessible](https://nordvpn.com/meshnet/remote-access/) picture library. Meshnet creates encrypted network tunnels between your image server and the connecting devices without [SSL certificates](https://nordvpn.com/blog/what-is-ssl/) or [port forwarding](https://nordvpn.com/blog/port-forwarding/).

This article describes how you can self-host a LibrePhotos picture library and access it remotely using Meshnet.

## Before you begin <a href="#before-you-begin" id="before-you-begin"></a>

To follow this guide, you must have [Docker](https://docs.docker.com/get-started/overview/) and [Docker Compose](https://docs.docker.com/compose/) installed on your device. Instructions on how to download and install these tools can be found on the Docker website:

* [Docker Desktop instructions for Windows](https://docs.docker.com/desktop/install/windows-install/)
* [Docker Desktop instructions for macOS](https://docs.docker.com/desktop/install/mac-install/)
* [Docker Desktop Instructions for Linux](https://docs.docker.com/desktop/install/linux-install/)
  * [Docker Engine instructions for Linux (CLI only)](https://docs.docker.com/engine/install/)
  * [Docker Compose instructions for Linux (CLI only)](https://docs.docker.com/compose/install/linux/)

{% hint style="info" %}
**Note**

Docker Compose comes pre-installed with Docker Desktop.
{% endhint %}

## Deploy LibrePhotos using Docker <a href="#deploy-librephotos-using-docker" id="deploy-librephotos-using-docker"></a>

The LibrePhotos instance consists of several containers, such as a database container and a container for the backend of the app. To make the deployment of multi-container applications more efficient, the Docker Compose tool is used.

### Preparing a working directory <a href="#preparing-a-working-directory" id="preparing-a-working-directory"></a>

For convenient deployment and management, prepare a specific directory where all LibrePhotos-related files will be located.

{% tabs %}
{% tab title="Windows" %}

1. Download the LibrePhoto Docker files from its [GitHub repository](https://github.com/LibrePhotos/librephotos-docker) by clicking **Code** > **Download ZIP**.<br>

   <figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FjtI03nekof3eqnGAkQfF%2Fwin_download_repo.png?alt=media&#x26;token=fbf70664-d0f6-414b-b041-fa58305862db" alt="Clicking &#x27;Download ZIP&#x27; in the LibrePhotos GitHub repository."><figcaption></figcaption></figure>

2. Open the downloaded archive and extract the `librephotos-docker` folder to an easily accessible location.

This will be the working directory of your LibrePhotos Docker container.
{% endtab %}

{% tab title="macOS and Linux" %}

1. Open **Terminal**.
2. Download the LibrePhotos Docker files from its [GitHub repository](https://github.com/LibrePhotos/librephotos-docker) by running the following `git clone` command:<br>

   ```bash
   git clone https://github.com/LibrePhotos/librephotos-docker.git
   ```

   &#x20;
3. Run the `ls` command to check if the `librephotos-docker` folder is present.\
   &#x20;

   <figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FEAhp4r73y0bPyfHRmGAx%2Flinux_ls_command.png?alt=media&#x26;token=bd8185e1-7580-4d77-872e-a1c47a2bb272" alt=""><figcaption></figcaption></figure>

This will be the working directory of your LibrePhotos Docker container.
{% endtab %}
{% endtabs %}

### Modifying the environment variables <a href="#modifying-the-environment-variables" id="modifying-the-environment-variables"></a>

Before deploying the container, you need to edit the parameters in the environment file. The variables in this file are used by Docker Compose to build the LibrePhotos instance.

{% tabs %}
{% tab title="Windows" %}

#### Create a new environment file <a href="#create-a-new-environment-file" id="create-a-new-environment-file"></a>

1. Open **PowerShell**.
2. Navigate to the `librephotos-docker` folder using the `cd` command.\
   \
   **Example**

   ```bash
   cd ~/Desktop/docker/librephotos-docker
   ```

   &#x20;
3. Run the following command to duplicate the sample environment file and name it `.env`:<br>

   ```bash
   copy librephotos.env .env
   ```

#### Specify your picture location <a href="#specify-your-picture-location" id="specify-your-picture-location"></a>

1. Open the newly created file using Notepad by running this command:

   ```bash
   notepad .env
   ```

   &#x20;

2. Set the value of `scanDirectory` to the path of your picture library by entering the path within single quotation marks (') after the equals sign, as shown:<br>

   <figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FmryGTi6ZJbqJHduj6KBy%2Fwin_env_changes1.png?alt=media&#x26;token=b8a8df14-d405-4a90-b409-51f805903c98" alt="Entering the path of the picture library."><figcaption></figcaption></figure>

3. Set the value of `data` to the path of the `librephotos-docker` folder by entering the folder’s path, followed by `/data` within single quotation marks (') after the equals sign, as shown:<br>

   <figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FyDlY1xSWIo0D7FxlzapF%2Fwin_env_changes2.png?alt=media&#x26;token=b8f5224e-d9b9-4ce3-a221-357782f90ffb" alt="Entering the path of the LibrePhotos data folder."><figcaption></figcaption></figure>

4. Press **Ctrl** + **S** to save changes.

5. Exit Notepad.

{% hint style="success" %}
**Tip**

If you want to change the port used by LibrePhotos, you can alter the number after the equal sign of the `httpPort` line.

![Line indicating the port of the LibrePhotos web interface.](https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FLcppzQX5vLWD02fZ9Lnm%2Fwin_default_port.png?alt=media\&token=4c7eedcd-0079-4b94-bf7d-1c1928bc04ea)
{% endhint %}
{% endtab %}

{% tab title="macOS and Linux" %}

#### Create a new environment file <a href="#create-a-new-environmental-file" id="create-a-new-environmental-file"></a>

1. Open **Terminal**.
2. Navigate to the `librephotos-docker` folder using the `cd` command.<br>

   **Example**

   ```bash
   cd ~/Docker/librephotos-docker
   ```

   &#x20;
3. Run the following command to duplicate the sample environment file and name it `.env`:

   ```bash
   cp librephotos.env .env
   ```

#### Specify your picture location <a href="#specify-your-picture-location.1" id="specify-your-picture-location.1"></a>

1. Open the newly created file using the Nano text editor by running this command:

   ```bash
   nano .env
   ```

   &#x20;

2. Set the value of `scanDirectory` to the path of your picture library by entering the path within single quotation marks (') after the equals sign, as shown:<br>

   **Example**

   <figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FkwK8PnWua3nYqGloOVWp%2Flinux_env_changes1.png?alt=media&#x26;token=aeb38790-6c88-4a6b-9dc5-8ea488a97020" alt="Entering the path of the picture library."><figcaption></figcaption></figure>

3. Set the value of `data` to the path of the `librephotos-docker` folder by entering the folder’s path, followed by `/data` within single quotation marks (') after the equals sign, as shown:<br>

   **Example**

   <figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FbeySqfB3gybPlYjP5IoS%2Flinux_env_changes2.png?alt=media&#x26;token=152bcdc6-3ae2-4dc0-ad2a-b4cbb2cc90dd" alt="Entering the path of the LibrePhotos data folder."><figcaption></figcaption></figure>

4. Press **Ctrl** + **X**, **Y**, and **Enter** to save changes and exit.

{% hint style="success" %}
**Tip**

If you want to change the port used by LibrePhotos, you can alter the number after the equal sign of the `httpPort` line.

![Line indicating the port of the LibrePhotos web interface.](https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FtARgMY4EXMeoNeiTOWaP%2Flinux_change_port.png?alt=media\&token=1250481c-fd7b-4be3-94d2-796ca2ebb9f3)
{% endhint %}
{% endtab %}
{% endtabs %}

### Deploying LibrePhotos <a href="#deploying-librephotos" id="deploying-librephotos"></a>

While in the `librephotos-docker` directory, execute the following command in the command line to start creating your LibrePhotos instance:

```bash
docker-compose up -d
```

Docker will [pull the resources](https://docs.docker.com/engine/reference/commandline/pull/) and dependencies required for LibrePhotos and create the required containers. You can expect the initial deployment to take several minutes.

## Set up your LibrePhotos web interface <a href="#set-up-your-librephotos-web-interface" id="set-up-your-librephotos-web-interface"></a>

With the containers up and running, you can access the web interface of LibrePhotos to configure your picture library. By default, the web interface listens on port 3000.

### Creating an administrator account <a href="#creating-an-administrator-account" id="creating-an-administrator-account"></a>

To control LibrePhotos, you must first create an administrator account. To create the account:

1. Open your internet browser and visit the following URL:\
   `localhost:3000/`<br>

2. Fill in the provided fields with your personal information, such as your username, email, and password, and click **Sign up**.\
   &#x20;

   <figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FpbTdyEYvRqmBBc3I9Kex%2Flibre_signup.png?alt=media&#x26;token=f46ed300-9673-4a7d-82e4-5f89f819e4b9" alt="Filling in the account details on the LibrePhotos sign up page."><figcaption></figcaption></figure>

3. On the login page, enter your username and password and click **Log in**.

{% hint style="info" %}
**Note**

If you see the login page instead of the account creation screen, reload the page.
{% endhint %}

### Scanning the picture library <a href="#scanning-the-picture-library" id="scanning-the-picture-library"></a>

At first, you will not see any images in your LibrePhotos web interface. This is because the tool has not yet scanned and indexed your pictures.

#### Perform the initial scan <a href="#perform-the-initial-scan" id="perform-the-initial-scan"></a>

To scan the picture library for the first time:

1. Click the **Edit user** button.

2. In the new window, under **Choose a directory from below**, click **data**.<br>

   <figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2Fn4KklDJqAqEBLTCUHuPq%2Flibre_choose_directory.png?alt=media&#x26;token=218b3b64-010b-4ede-b46f-dfc2f2867c92" alt="Selecting the picture directory."><figcaption></figcaption></figure>

3. Click **Save**.

LibrePhotos will start scanning all files in the directory that was specified in the `.env` file. Once the scan is over, you will see a Finished message in the lower-right corner of the screen.

To see all of the pictures, reload the page.

#### Add more pictures <a href="#add-more-pictures" id="add-more-pictures"></a>

LibrePhotos does not automatically scan the added folders. This means newly added pictures will not appear until you re-scan the folders. To start a scan:

1. Click the user icon in the upper-right corner and select **Library**.
2. Under **Photos**, click the **Scan photos (filesystem)** button.

Once the scan finishes, you will see a Finished message in the lower-right corner of the page.

### Creating albums <a href="#creating-albums" id="creating-albums"></a>

By default, all images are sorted by their creation date. However, you may want to categorize your pictures into albums for a more convenient user experience. To create albums:

1. Under **Photos**, click the Toggle select mode button.\
   &#x20;

   <figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2Fwv5o3uu7Z4aEgj5XHNJW%2Flibre_select_pics.png?alt=media&#x26;token=0963cbd4-d2ff-4ace-926d-5f4a0d4f92e6" alt="Clicking the &#x27;Toggle select mode&#x27; button."><figcaption></figcaption></figure>

2. Select the pictures you want to include in your album by clicking them.

3. Click the plus (+) button on the right and select **Album**.<br>

   <figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2F1XX0btfArI8bnhWz2XZo%2Flibre_select_pics2.png?alt=media&#x26;token=9303a3e3-a4cc-48a5-9edc-796f3b007573" alt="Selecting &#x27;Album&#x27; form the list of options."><figcaption></figcaption></figure>

4. Under **New album**, enter the name of your album and click **Create**.

To view the new album and its contents, select **Albums** > **My albums** from the left-side menu.

<figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FBWq83qXARfUq3fVNcU1E%2Flibre_albums.png?alt=media&#x26;token=9e924e04-f278-4d19-b843-1cae2658133e" alt="My albums sections of LibrePhotos."><figcaption></figcaption></figure>

### Creating new users <a href="#creating-new-users" id="creating-new-users"></a>

Giving administrator access to other people may pose risks. It is good practice to have dedicated user accounts for people who only want to view the pictures, but should not have control over the library’s settings. To create additional users:

1. Click the user icon in the upper-right corner and select **Admin area**.

2. Under **Users**, select **Add new user**.

3. Fill in the required fields for the new user.<br>

   <figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FhHdpQoW0P4l1590Oh4vq%2Flibre_create_user1.png?alt=media&#x26;token=653f1bfc-9283-41e4-a56c-b9033885f0bc" alt="Filling in details for a new user account."><figcaption></figcaption></figure>

4. Under **Choose a directory from below**, click the dropdown arrow next to **data**.

5. Select the folder that you want the user to see pictures from.<br>

   <figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FFKhhFFm1Y51PvSsqDte4%2Flibre_create_user2.png?alt=media&#x26;token=d02e3760-63e3-43a6-94ea-28ff9cd52879" alt="Selecting a folder."><figcaption></figcaption></figure>

6. Click **Save**.

You can see the newly created account under **Users** after reloading the page.

<figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FDeYHbPSNxyspOy9BdekD%2Flibre_create_user3.png?alt=media&#x26;token=ac625606-eed0-4f77-bde9-36c6e6993788" alt="New user visible in the Users table."><figcaption></figcaption></figure>

## Access your picture library over Meshnet <a href="#access-your-picture-library-over-meshnet" id="access-your-picture-library-over-meshnet"></a>

With the pictures indexed and visible, you can share your photo library with others or access it remotely yourself. To access your LibrePhotos instance using Meshnet:

1. Copy the Nord name of the device hosting LibrePhotos from the NordVPN application.

2. Open your internet browser.

3. In the URL field, paste the copied Nord name followed by `:3000` and press **Enter**.\
   \
   **Example**

   <figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FFo0kzx2Mt79AEO6qnS1f%2Flibre_mesh_access.png?alt=media&#x26;token=3ecf2969-7be0-45f0-a69d-60058ca7cb12" alt="Accessing LibrePhotos using the Nord name."><figcaption></figcaption></figure>

4. Enter your username and password and click **Login**.

You can now freely browse the picture library from a remote location without compromising your device’s security.

<figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2Fzc79pTbf9zN2dttojCZ0%2Flibre_mesh_access2.png?alt=media&#x26;token=6fe2111f-5a96-49d5-8020-a68e57e5dbda" alt="Browsing LibrePhotos over Meshnet."><figcaption></figcaption></figure>
