How to Install Piwigo on Ubuntu 22.04 LTS

Estimated reading: 4 minutes 13 views

Introduction

 

Piwigo is a robust open-source photo gallery platform that makes it easy to manage, organize, and share your photo collections online. With a user-friendly interface and a wide range of features, Piwigo is popular among individuals, photographers, and organizations.

This guide walks you through the complete process of installing Piwigo on Ubuntu Server 22.04, ensuring a clean and functional deployment.


Software Stack

  • Operating System: Ubuntu 22.04 LTS

  • Web Server: Apache

  • PHP Version: 8.1

  • Database: MariaDB 10.x


1. System Preparation

Update package lists and upgrade existing packages:

apt update && apt upgrade -y
  • apt update: Retrieves the latest package list from configured repositories.

  • apt upgrade -y: Installs the newest versions of all installed packages (with -y to auto-confirm prompts).

Clean up unnecessary packages:

apt autoremove -y && apt autoclean
  • apt autoremove: Removes packages that were automatically installed to satisfy dependencies but are no longer needed.

  • apt autoclean: Deletes local copies of package files that can no longer be downloaded.


2. Configure the UFW Firewall

Set default policies:

ufw default allow outgoing
ufw default deny incoming
  • Allow all outgoing connections.

  • Deny all incoming connections by default for security.

Allow essential ports:

ufw allow 22
ufw allow 80
ufw allow 443
  • 22: SSH access.

  • 80: HTTP traffic.

  • 443: HTTPS traffic.

Enable and check UFW:

ufw enable
ufw status
  • ufw enable: Turns on the firewall.

  • ufw status: Displays current rules and status.


3. Install Required Packages

Apache, MariaDB, PHP, extensions, and utilities:

apt install apache2 mariadb-server libapache2-mod-php php php-gmp php-bcmath php-gd php-json php-mysql php-curl php-mbstring php-intl php-imagick php-xml php-zip php-fpm php-apcu php-opcache bzip2 zip unzip imagemagick vim libimage-exiftool-perl ffmpeg -y

Includes:

  • Web server: apache2

  • Database server: mariadb-server

  • PHP Core + Extensions: for performance, uploads, media processing

  • Utilities: imagemagick, ffmpeg, zip, unzip, vim, exiftool


4. Enable PHP-FPM and Optimize Apache Configuration

Enable PHP-FPM:

a2enconf php8.1-fpm
  • Enables PHP 8.1 FPM config so Apache can handle PHP using FPM instead of mod_php.

Disable default PHP and MPM modules:

a2dismod php8.1
a2dismod mpm_prefork
2enmod mpm_event
  • Disables traditional PHP processing (mod_php) and switches Apache to event MPM (better performance with FPM).


5. Enable Required Apache Modules

a2enmod ssl rewrite headers deflate cache http2 proxy_fcgi env expires
  • ssl: Enables HTTPS support

  • rewrite: Enables URL rewriting (pretty URLs)

  • headers: Allows modifying HTTP headers

  • deflate: Compression for faster loading

  • cache, http2: Performance enhancements

  • proxy_fcgi: Required for PHP-FPM

  • env, expires: Control caching and environment vars

Restart Apache:

systemctl restart apache2

6. Enable Services to Start on Boot

systemctl enable apache2
systemctl enable php8.1-fpm
systemctl enable mariadb
  • Ensures all necessary services will start automatically after reboot.


7. Secure and Configure MariaDB

Run security script:

mysql_secure_installation
  • Sets root password, removes anonymous users, disables remote root login, removes test DB.

Access MariaDB shell:

mariadb -u root -p

Inside MariaDB shell:

CREATE DATABASE piwigo CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
GRANT ALL ON piwigo.* TO 'piwigo_user'@'localhost' IDENTIFIED BY 'PASSWORD';
FLUSH PRIVILEGES;
EXIT;
  • Creates database for Piwigo

  • Creates a dedicated user with full access

  • Don’t forget to replace 'PASSWORD' with a secure password


8. Adjust PHP Configuration

Edit PHP FPM config:

nano /etc/php/8.1/fpm/php.ini

Modify these values:

max_execution_time = 180 ; Line ~409
memory_limit = 512M ; Line ~430
post_max_size = 200M ; Line ~698
upload_max_filesize = 200M ; Line ~850

These settings ensure large file uploads and better script execution time.

Restart PHP-FPM:

systemctl restart php8.1-fpm

9. Configure Apache Virtual Host

Create new virtual host file:

cd /etc/apache2/sites-available/ nano piwigo.conf

Paste the following configuration :

<VirtualHost *:80>
                 DocumentRoot /var/www/html
                 <Directory "/var/www/html">
                                    AllowOverride All
                                   Options -Indexes +FollowSymLinks   
                 </Directory>
                ErrorLog /var/log/apache2/piwigo_error.log
</VirtualHost>

Enable virtual host and check config:

a2dissite 000-default.conf
a2ensite piwigo.conf
apachectl -t
systemctl restart apache2
  • Disables default site, enables your new site

  • apachectl -t: Tests Apache config syntax


10. Download and Deploy Piwigo

Download latest release:

cd /var/www
wget https://github.com/Piwigo/Piwigo/archive/refs/tags/13.7.0.zip

Unzip and deploy:

unzip 13.7.0.zip
rm /var/www/html/index.html
shopt -s dotglob
mv Piwigo-13.7.0/* html/

Set correct permissions:

chown -R www-data:www-data /var/www/html

11. Complete Installation in Browser

  • Go to: http://your-domain.com

  • Fill in database details:

    • Database: piwigo

    • User: piwigo_user

    • Password: The one you set

  • Set admin login and password

  • Click Start installation

Conclusion

You have now successfully installed and configured Piwigo on your Ubuntu 22.04 server. The gallery is ready to use—feel free to explore themes, plugins, and start uploading your photos.

Share this Doc

How to Install Piwigo on Ubuntu 22.04 LTS

Or copy link

CONTENTS