How to Install Piwigo on Alpine Linux Latest

Piwigo is a free and open-source software for creating photo galleries on the web. In this tutorial, we will learn how to install Piwigo on Alpine Linux.

Prerequisites

Before we begin, make sure you have the following:

Step 1: Install Required Packages

First, update the Alpine package index and install the required packages using the following command:

apk update && apk upgrade
apk add nginx openssl php7 php7-fpm php7-opcache php7-gd php7-zip php7-zlib php7-zip php7-mbstring php7-json php7-curl php7-iconv php7-gmp php7-xml php7-fileinfo php7-xmlwriter php7-session php7-mysqli php7-pdo_mysql php7-pdo_sqlite php7-pdo_odbc php7-pdo_firebird php7-pdo_pgsql php7-pdo_dblib php7-simplexml php7-dom

This command will install Nginx web server, OpenSSL for secure connections, and various PHP libraries required by Piwigo.

Step 2: Create Nginx Configuration File

Next, create a new Nginx configuration file for Piwigo by creating the /etc/nginx/conf.d/piwigo.conf file with the following contents:

server {
    listen       80;
    server_name  example.com;

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

    location ~* \.(gif|jpg|jpeg|png|bmp|ico|svg)$ {
        expires      30d;
    }

    location ~* \.(pdf|zip|rar|tar|bz2|gz|doc|xls|exe|ppt|txt|tar.gz)$ {
        expires      30d;
    }

    location ~ \.php$ {
        include       fastcgi_params;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

Replace example.com with your own domain name.

Step 3: Download and Install Piwigo

Download the latest stable version of Piwigo from the official website using the following command:

cd /var/www
wget -O piwigo.zip https://piwigo.org/download/dlcounter.php?code=latest
unzip piwigo.zip

This will download and extract the latest version of Piwigo into the /var/www/piwigo directory.

Step 4: Configure Piwigo

Next, create a new configuration file for Piwigo by copying the config_default.inc.php file to config.inc.php using the following command:

cp /var/www/piwigo/include/config_default.inc.php /var/www/piwigo/config/config.inc.php
vi /var/www/piwigo/config/config.inc.php

In the config.inc.php file, update the following fields:

$conf['dbHost'] = 'localhost';
$conf['dbUser'] = 'piwigo';
$conf['dbPassword'] = 'password';
$conf['dbName'] = 'piwigo';

Replace password with a strong password of your choice.

Step 5: Set Permissions

Next, set the correct ownership and permissions of the Piwigo files using the following command:

chown -R nginx:nginx /var/www/piwigo
chmod -R 750 /var/www/piwigo

These commands will set Nginx as the owner and group of the Piwigo files, and allow only the owner and group to read, write and execute the necessary files.

Step 6: Enable Services

Finally, enable the Nginx and PHP services using the following commands:

rc-update add nginx
rc-update add php-fpm7
service nginx start
service php-fpm7 start

These commands will add Nginx and PHP-FPM to the system startup, and start both services.

Step 7: Access Piwigo

You can now access Piwigo by opening a web browser and navigating to http://example.com. You should see the default Piwigo login page.

Conclusion

In this tutorial, we have learned how to install Piwigo on Alpine Linux and configure it to work with Nginx and PHP-FPM. You can now start adding your photos and enjoy your new photo gallery!

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!