How to Install PhotoPrism on OpenBSD

PhotoPrism is an open-source photo management application that allows users to store, organize, and share their photos. In this tutorial, we will go through the installation process of PhotoPrism on OpenBSD.

Prerequisites

Before we begin, make sure that you have the following prerequisites:

Step 1: Install Required Dependencies

The first step in the installation process is to install required dependencies for PhotoPrism. OpenBSD has most of the essential dependencies like Go, SQLite, and Git pre-installed. However, you may need to install some additional packages like GCC if it's not already installed on your system.

You can install GCC with the following command:

$ su -c "pkg_add -v gcc"

If GCC is already installed on your OpenBSD system, you can skip this step.

Step 2: Download and Install PhotoPrism

Once you have installed the necessary dependencies, you can start installing PhotoPrism by downloading its binary file from the official website. You can download the latest binary file using the following command:

$ wget https://dl.photoprism.org/photoprism_x.x.x_openbsd_amd64.tar.gz

Note: Replace "x.x.x" with the latest version of PhotoPrism available.

Once the download is complete, extract the binary file with the following command:

$ tar -xvzf photoprism_x.x.x_openbsd_amd64.tar.gz

Now, move the extracted PhotoPrism binary file to the /usr/local/bin directory. Use the following command to do so:

$ su -c "cp photoprism /usr/local/bin/"

Next, we will create a new user for PhotoPrism, which is usually the recommended way to run any service or application on OpenBSD.

Step 3: Create a User for PhotoPrism

You can create a new user for PhotoPrism with the useradd command as shown below:

$ su -c "useradd -r -d /var/photoprism -M -N -s /sbin/nologin photoprism"

This command creates a new system user photoprism with a home directory of /var/photoprism and /sbin/nologin shell, which prevents the user from logging in to the system. This user will be used to run the PhotoPrism service.

Next, we will create the necessary directories and permissions for the photoprism user.

Step 4: Create Directories and Permissions

You need to create some directories and set appropriate permissions for the photoprism user. Run the following commands to create the required directories and set permissions:

$ su -c "mkdir -p /var/photoprism/data"
$ su -c "chmod -R 775 /var/photoprism"
$ su -c "chown -R photoprism:photoprism /var/photoprism"

These commands create a new directory /var/photoprism/data for PhotoPrism to store its data, sets appropriate permissions for the directory, and gives ownership to the photoprism user.

Now, we need to create a configuration file for PhotoPrism.

Step 5: Create a Configuration File

We need to create a configuration file config.yml for PhotoPrism to define its settings. Run the following command to create the file:

$ su -c "touch /var/photoprism/config.yml"

Now, edit the file config.yml and add the following content:

log-level: info
data:
  dir: /var/photoprism/data
index:
  type: bleve
  bleveStoreType: boltdb
server:
  httpAddr: ":2342"
  httpsAddr: ""
  secret: My_Secret_Pragramming_Key
  httpRootRedirect: /ui/
  publicUrl: ""
  urlBasePath: ""
  readTimeout: 10s
  writeTimeout: 30s
  idleTimeout: 120s
  maxHeaderBytes: 1<<20
  cors:
    enabled: true
    allowedOrigins:
      - "*"
    allowedMethods:
      - "GET"
      - "HEAD"
      - "PUT"
      - "POST"
      - "DELETE"
      - "OPTIONS"
      - "TRACE"
      - "CONNECT"
preview:
  enable: true
  maxWidth: 1920
  maxHeight: 1920
  jpegQuality: 85
  webpQuality: 85
  sizes:
    - 320x0
    - 480x0
    - 640x0
    - 800x0
    - 960x0
    - 1280x0
    - 8x1024

Make sure to replace the secret key value with your preferred secret key.

Step 6: Launch PhotoPrism

Now that we have configured our system and created a configuration file for PhotoPrism, we can start the photo management server using the following command:

$ su -c "setcap 'cap_net_bind_service=+ep' /usr/local/bin/photoprism"
$ su -c "/usr/local/bin/photoprism start"

The first command above will give the photoprism user the required capabilities to bind to low ports (like port 80 and 443). The second command starts the PhotoPrism service.

Once PhotoPrism is up and running, access it from a web browser using the IP address or hostname of your OpenBSD machine followed by port 2342. For example, if your machine IP is 192.168.0.10, you can access PhotoPrism with the following URL:

http://192.168.0.10:2342

Note: Make sure to open the port 2342 on your firewall to allow incoming requests.

Conclusion

Congratulations! You have successfully installed PhotoPrism on OpenBSD. With PhotoPrism, you can now store, organize, and share your photos with ease.

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!