56tvmao: How-to instructions you can trust. Linux Make a Custom Web Gallery with Piwigo

Make a Custom Web Gallery with Piwigo

If you’re a visual artist or someone who collects a lot of images, you may have a need for a custom web gallery on your website. There’s more than one way to go about creating one – you can hand-code it, use a plugin on a content management system (CMS), or use dedicated gallery software. Piwigo is an extensible, open-source photo gallery software that you can install on VPS and webhosts. In this article, we’ll walk through installing and setting up a custom web gallery with Piwigo.

Content

Installing Piwigo

The easiest way to get started with Piwigo is by installing it on a shared webhost. One of the advantages of Piwigo over other photo gallery servers is that it uses PHP. This makes it easy to run even on systems where you can’t access the root user.

To begin, create a new database in your webhost control panel. If your site uses cPanel, go to the MySQL Databases section to do so.

Make sure to add a user to the new database and grant it all the privileges on the database.

After you’ve set up a database, installing Piwigo couldn’t be easier. Your Web hosting provider may offer an automated installer, but I recommend getting Piwigo straight from the official download page to ensure that you get the latest version.

Extract the Piwigo .zip file on your Downloads directory, then copy the “piwigo” folder to the root of your shared webhost directory. In my case, I will use my FTP client to send it to my webhost root.

Open a new browser tab, then navigate to your shared webhost’s domain followed by the path to your Piwigo directory. Since I’ve copied mine to my webhost’s root directory, I only need to provide “/piwigo/install.php” at the end of my URL.

This will bring up the installation and setup screen for Piwigo. Provide the details of your MySQL database, along with the username and password for your administrator account.

Open a new browser tab, then navigate to the URL of your Piwigo instance to check if it’s working properly.

Good to know: Piwigo is just one of the many gallery software suites today. Check out our list of the best self-hostable photo galleries to see which one is right for you.

Installing Piwigo on a VPS

Aside from installing on a shared webhost, it’s also possible to run Piwigo on a dedicated VPS box. Doing this gives you control and flexibility over the programs that run alongside Piwigo. In this section, I will install Piwigo on an Ubuntu 24.04 server.

Note: installing Piwigo on its own VPS requires an appropriate DNS A record for your machine that points to its IPv4 address.

Start by making sure that your system is currently up-to-date:

sudo apt update && sudo apt upgrade

Install the dependencies for your Piwigo instance by running the following command:

sudo apt install nginx php mariadb-server imagemagick ffmpeg php-fpm php-mbstring php-gd php-mysql php-imagick php-xml unzip

Switch to the root user, run initial setup prompt for MariaDB, then go inside the MariaDB console:

sudo -s
sudo mariadb-secure-installation
sudo mariadb -u root

Note: the setup script for MariaDB will ask you a bunch of questions about how you want to secure your database. For most cases, it’s safe to accept the script’s default values.

Creating the database and running Piwigo

Once inside MariaDB, create a simple database for your Piwigo instance:

CREATE DATABASE piwigo;

Run the following command to create a new user and set its permissions to access the new Piwigo database:

CREATE USER 'youruser'@'localhost' IDENTIFIED BY 'userpassword';
GRANT ALL ON piwigo.* TO 'youruser'@'localhost';

Press Ctrl + D to exit the MariaDB console, then run the following command to create the site config file for Piwigo:

sudo vim /etc/nginx/sites-available/piwigo

Paste the following block of code inside your new site config file:

server {
        listen 80;
        server_name YOUR-ROOT-DOMAIN.HERE;
        root /var/www/piwigo;
 
        index index.html index.htm index.php;
 
        location / {
                try_files $uri $uri/ =404;
        }
 
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
        }
 
        location ~ /\.ht {
                deny all;
        }
}

Save your new config file, then create a symbolic link from the “/etc/nginx/sites-available” to “/etc/nginx/sites-enabled.”

sudo ln -s /etc/nginx/sites-available/piwigo /etc/nginx/sites-enabled

Navigate to your server’s webroot directory, then download the .zip file for Piwigo:

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

Extract the entire Piwigo setup on the webroot directory, then set its appropriate permission and ownership bits:

unzip /var/www/piwigo.zip
sudo chown -R www-data:www-data /var/www/piwigo
sudo chmod -R 755 /var/www/piwigo

Enable both the PHP-fpm and Nginx services to start your Piwigo instance:

sudo systemctl enable --now php8.3-fpm.service
sudo systemctl disable --now apache2.service
sudo systemctl enable --now nginx.service

Confirm that Piwigo is running properly by opening a web page and navigating to your domain name.

On a side note: do you have an old Raspberry Pi just gathering dust? Learn how to convert your Pi into a local photo backup solution.

Getting Started With Using Piwigo

At this point, you now have a working Piwigo instance running on either your webhost or VPS. To start using it, click the I want to add photos button on your gallery homepage.

Doing this will bring up the administration page for Piwigo where you can upload and configure aspects of your instance. Click the Create a first album button to start your online web gallery.

Provide a name for your new album, click Create and Select to go into your abum config page.

Either click the Add Photos button or drag the photos that you want to upload to your server on the album webpage.

Once you have the photos that you want in the Piwigo page, click Start Upload to begin the upload process.

Once you’ve added at least one album, you can visit your Piwigo URL and view the gallery.

Configuring Piwigo

By default, Piwigo names a new web gallery as “Just another Piwigo gallery.” You’ll probably want to change this generic title. To do so, click the Admin button on the gallery’s upper right corner.

Select Configuration -> Options on the left sidebar.

Provide the new name of your Piwigo gallery on the Gallery title textbox, then click Save settings to apply it.

Changing the Gallery Theme in Piwigo

Apart from changing the gallery name, it’s also possible to change the look of your Piwigo instance. For that, click the Themes category on the admin page’s left sidebar.

In here, you can either select the default theme or enable an inactive theme on your web gallery. For instance, clicking Activate on the Elegant theme will put it on your instance’s theme list.

Note: you can also force a theme be the default for your gallery by clicking the “Set as Default” button.

Further, Piwigo also provides a catalog of beautiful third-party themes that you can install for your gallery. To access this, click the Add new theme tab on the Themes config page.

Scroll through the third-party themes, then click Install on the one that you want.

Lastly, go to your instance’s theme list, then click Activate to add it to your active theme selection.

Installing Plugins in Piwigo

There are two ways to install plugins in Piwigo. First, you can use the built-in plugins feature, which handles extension installation and management. Second, you can manually install your extension by copying it to Piwigo’s plugins directory.

To use the built-in function, navigate to the Plugins category on your instance’s Administration page.

Click the Add a new plugin tab to look at the available extensions for your Piwigo gallery.

To manually install a plugin, first go to the official plugin page for Piwigo and look for an extension that you want to install. In my case, I wanted to use the “Community” plugin to add user submissions to my gallery.

Download the plugin .zip file, then transfer it to your Piwigo instance. For instance, the following command uses SCP to transfer the plugin archive to my VPS:

scp ~/Downloads/community_15.a.zip ramces@mte-ubuntu-server:~

Go to your Piwigo instance, then move and extract the plugin’s .zip file to your gallery’s plugins directory:

sudo cp ~/community_15.a.zip /var/www/piwigo/plugins
sudo cd /var/www/piwigo/plugins
sudo unzip ./community_15.a.zip && sudo rm ./community_15.a.zip

Note: if you’re running Piwigo on a VPS, make sure that your webserver can read your plugins folder: sudo chown -R www-data:www-data /var/www/piwigo/plugins.

Confirm that you’ve installed your new plugin properly by visiting the Plugins page on your Piwigo admin screen.

Recommended Plugins for Piwigo

With that in mind, I’ll go through some of the plugins that I’ve found useful on while tinkering my personal Piwigo instance.

1. PersoFavicon

You might be used to uploading your own favicon to a website and seeing it show up automatically in your browser. Unfortunately, this doesn’t work in Piwigo. To use your own favicon in Piwigo, install the PersoFavicon plugin.

Once activated, it will show up in your administrator sidebar under Plugins. Click on it to upload a favicon in .ico format.

2. Embedded Videos

Embedded Videos lets you embed external video files in addition to images in your Piwigo gallery. At the moment, it supports any video coming from YouTube, Vimeo, and Dailymotion.

To include videos to your albums, click the Settings button underneath the Embedded Videos plugin box. Doing this will bring up the config page for Embedded Videos. The plugin interface lets you add one video at a time by URL.

Note: ticking the Add film effect checkbox will include filmstrip bars on the sides of your embeds to indicate that the gallery entry is a video file.

3. Expiry Date

Expiry Date is a neat plugin that implements temporary images on your Piwigo gallery. It provides an automatic image deletion system and the ability to notify you when it expires. As a privacy-conscious individual, I find this extension highly valuable since it allows me to have finer control over how I share pictures online.

To use this plugin, go to your Piwigo instance’s admin page and upload a new image.

Once done, click Manage this set of photos, then select the images that you want to set the timer on.

Scroll down to the Actions section, select “Expiry Date” on the dropdown menu, then provide the date when you want your images to expire.

4. Community

Community is a simple plugin that addresses Piwigo’s single-user focus. It extends the gallery’s multi-user support and allows them to create folders and upload images on your Piwigo instance. Coupled with decent access control features, Community is a must-have plugin for anyone who wants to start a collaborative photo album.

To get started with Community, go to your Piwigo instance’s plugins page, then click Settings underneath the plugin box.

Click Add a permission, then set the permissions you want for your gallery. In my case, I want all users to be able to upload to the “maketecheasier” folder.

5. Piwigo-openstreetmap

Piwigo-openstreetmap is a handy plugin that displays the GPS data embedded on modern JPEG images. To achieve this, the plugin uses OpenStreetMap data to show the exact location of where you took your photos. This makes it a great companion to a GPS tracking server such as uLogger.

Once the plugin is up and running, piwigo-openstreetmap should work right out of the box. If you already have images in your gallery with a geolocation tag, the plugin will immediately display a map showing where you took your photos.

I have been using Piwigo for a couple of months and it’s become my favorite Web-based photo gallery software. Managing a custom web gallery with Piwigo is incredibly simple, from setting up photos and albums to upgrading your installation.

Learning how to install and use Piwigo as an online gallery for your photos is just the first step in creating your own self-hosted platform on the internet. Dive deeper into the wonderful world of self-hosting by checking out how a fellow writer turned his Raspberry Pi into a private Internet Archive.

Image credit: Glenn Carstens-Peters via Unsplash. All alterations and screenshots by Ramces Red.


Ramces Red
Staff Writer

Ramces is a technology writer that lived with computers all his life. A prolific reader and a student of Anthropology, he is an eccentric character that writes articles about Linux and anything *nix.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Sign up for all newsletters.
By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time. Subscribe

Related Post