How to Install PiGallery 2 on Alpine Linux

PiGallery 2 is a self-hosted photo gallery application that has a modern look and feel. It provides a simple and easy interface to manage your photo collection. In this tutorial, you will learn how to install PiGallery 2 on Alpine Linux.

Prerequisites

Before we start, make sure you have the following:

  • A server running with the latest version of Alpine Linux.
  • Login credentials with sudo access.

Step 1: Install System Packages

First, you need to install the necessary system packages for PiGallery 2 to work. Run the following command to install them:

sudo apk add --update --no-cache php7 php7-fpm nginx imagemagick

Step 2: Configure Nginx

Now you need to configure Nginx for PiGallery 2.

  • Start by removing the default Nginx configuration:
sudo rm /etc/nginx/conf.d/default.conf
  • Create a new Nginx configuration file with the following contents:
server {
    listen 80 default_server;
    root /var/www/html;
    client_max_body_size 100M;
    index index.php index.html index.htm;
    
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
    
    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php-fpm7.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param QUERY_STRING $query_string;
        fastcgi_intercept_errors on;
        fastcgi_buffer_size 256k;
        fastcgi_buffers 4 256k;
    }
}
  • Save and exit the file.

  • Restart Nginx:

sudo rc-service nginx restart

Your web server is now ready to host PiGallery 2.

Step 3: Install PiGallery 2

  • Download PiGallery 2 from the following link:
wget https://github.com/bpatrik/pigallery2/releases/download/vXXX/pigallery2_vXXX.zip

(Replace XXX with the current version number)

  • After downloading, extract the files:
unzip pigallery2_vXXX.zip -d /var/www/html/

(Replace XXX with the current version number)

  • Change the ownership to the www-data user:
sudo chown www-data:www-data /var/www/html/ -R

Step 4: Configure PiGallery 2

  • Edit the configuration file:
sudo nano /var/www/html/config.php
  • You can configure various settings in this file as per your preference.

  • Once done, save and exit the file.

Step 5: Start Services

  • Start the PHP-FPM service:
sudo rc-service php-fpm7 start
  • Start the Nginx service:
sudo rc-service nginx start

You have successfully installed and configured PiGallery 2 on Alpine Linux. You can access it by navigating to your server's IP address or domain name in your web browser.

Conclusion

This tutorial covered the installation process of PiGallery 2 on Alpine Linux, which provides an easy way to create a self-hosted photo gallery.