How to install HomeGallery on NetBSD

HomeGallery is a free and open-source web-based photo gallery software that can be used to showcase your photos, videos, and other visual content. In this tutorial, we will walk you through the steps of installing HomeGallery on NetBSD.

Prerequisites

Before you begin the installation process, make sure that you have the following:

Step 1: Update packages

It is always recommended to update your package manager before installing any new software. Run the command below to update packages:

pkgin update

Step 2: Install required packages

The HomeGallery software requires PHP and some PHP modules to run. Run the following command to install PHP and its modules:

pkgin install php73-7.3.29nb1 php73-gd-7.3.29nb1 php73-mbstring-7.3.29nb1 php73-pdo_mysql-7.3.29nb1

Step 3: Download HomeGallery

The HomeGallery software can be downloaded from the official website or GitHub. Run the command below to clone the HomeGallery repository from GitHub:

git clone https://github.com/HomeGallery/homegallery.git /var/www/homegallery

Step 4: Configure HomeGallery

Open the config/config.yml file using your favorite text editor and edit the following settings:

server:
  # URL of your HomeGallery installation
  url: http://yourdomain.com

database:
  # MySQL database hostname
  hostname: localhost
  # MySQL database name
  name: homegallery
  # MySQL database username
  username: yourusername
  # MySQL database password
  password: yourpassword

Save the changes and exit the editor.

Step 5: Setup database

Create a new MySQL database for HomeGallery with the following command:

echo "create database homegallery" | mysql -u root -p

Import the database schema using the following command:

mysql -u yourusername -p homegallery < /var/www/homegallery/schema/homegallery.sql

Step 6: Set directory permissions

Run the following command to set the directory permissions:

chown -R www /var/www/homegallery

Step 7: Install and setup webserver

If you do not have a webserver installed, you can install Nginx or Apache. For Nginx installation, run the following command:

pkgin install nginx

For Apache installation, run the following command:

pkgin install apache

Once the webserver is installed, create a new virtual host configuration for HomeGallery. For Nginx, create the following configuration file /usr/pkg/etc/nginx/vhosts/homegallery.conf:

server {
  listen 80;
  server_name yourdomain.com;
  root /var/www/homegallery/public;
  index index.php index.html;

  location / {
    try_files $uri $uri/ /index.php?$query_string;
  }

  location ~ \.php$ {
    fastcgi_pass unix:/var/run/php-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
  }
}

For Apache, create the following configuration file /usr/pkg/etc/httpd/conf/vhosts/homegallery.conf:

<VirtualHost *:80>
    ServerName yourdomain.com
    DocumentRoot /var/www/homegallery/public
    DirectoryIndex index.php index.html

    <Directory /var/www/homegallery/public>
        Options -Indexes +FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    <IfModule mod_php73.c>
        php_admin_value date.timezone Europe/Berlin
        php_admin_value upload_max_filesize 32M
        php_admin_value post_max_size 32M
        php_admin_value memory_limit 256M
    </IfModule>
</VirtualHost>

Note that you may need to modify the configuration files to match your specific setup.

Step 8: Start webserver and PHP

After you have created the virtual host configuration, start both the webserver and PHP with the following command:

For Nginx:

rcctl enable nginx
rcctl start nginx
rcctl enable php73_fpm
rcctl start php73_fpm

For Apache:

rcctl enable apache24
rcctl start apache24

Step 9: Access HomeGallery

You can now access your HomeGallery installation by visiting your configured domain name in your web browser.

Conclusion

Congratulations, you have successfully installed HomeGallery on NetBSD. You can now add your photos, videos, and other visual content to your gallery and showcase them to others.

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!