How to Install PiGallery 2 on Ubuntu Server

PiGallery 2 is an open-source web-based photo gallery application written in JavaScript. It is easy to use, fast, and highly customizable. This tutorial will guide you through the process of installing PiGallery 2 on Ubuntu Server.

Prerequisites

Before starting with the installation, make sure that you have the following prerequisites:

  1. A Ubuntu Server latest version running machine.
  2. An SSH client like Putty (if you are using a Windows machine to connect Ubuntu Server) or Terminal (if you are using a Mac machine to connect Ubuntu Server).
  3. A sudo user access.

Step 1: Update and Upgrade the Ubuntu System

It is always recommended to update and upgrade the Ubuntu system before installing any new application. To update the system, run the following command:

sudo apt-get update

And to upgrade the system, run the following command:

sudo apt-get upgrade

Step 2: Install Required Dependencies

PiGallery 2 requires some dependencies to work correctly. Run the following command to install the necessary dependencies:

sudo apt-get install apache2 php7.4 php7.4-curl php7.4-gd php7.4-mbstring php7.4-xml php7.4-zip libapache2-mod-php7.4

Step 3: Download and Extract the PiGallery 2

PiGallery 2 is available on Github repository. Visit the PiGallery2 Github page and copy the URL of the latest version. Then, run the following command on your Ubuntu Server:

sudo wget https://github.com/bpatrik/pigallery2/releases/download/v2.2.2/pigallery2-2.2.2.zip

If the above command did not work then, you can use the following command to download the latest version of PiGallery 2:

sudo wget https://github.com/bpatrik/pigallery2/releases/latest/download/pigallery2-latest.zip

Then, extract the downloaded zip file using the following command:

sudo apt-get install unzip

sudo unzip pigallery2-2.2.2.zip

Here in the above example, we have downloaded and extracted the 2.2.2 version of PiGallery 2. You can download the latest release and use it in this step.

Step 4: Move PiGallery 2 files to Web Directory

Now, move the extracted PiGallery 2 files to the web directory using the following command:

sudo mv pigallery2 /var/www/html/

Step 5: Set Permissions

Set the correct permissions for the /var/www/html/pigallery2 directory using the following command:

sudo chown -R www-data: /var/www/html/pigallery2
sudo chmod -R 755 /var/www/html/pigallery2

Step 6: Configure Virtual Host

To configure the virtual host for PiGallery 2, create a configuration file called pigallery2.conf in the /etc/apache2/sites-available/ directory using the following command:

sudo nano /etc/apache2/sites-available/pigallery2.conf

Then, add the following content to the file and save it:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/pigallery2
        <Directory /var/www/html/pigallery2>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Require all granted
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Now, enable the virtual host using the following command:

sudo a2ensite pigallery2.conf

Step 7: Restart Apache Server

Finally, restart the Apache web server using the following command:

sudo systemctl restart apache2

Step 8: Access PiGallery 2

You can now access PiGallery 2 by going to your web browser and typing http://your_server_ip/pigallery2. You will be presented with a setup wizard where you can configure PiGallery 2 for your needs.

Conclusion

In this tutorial, we have learned how to install PiGallery 2 on a Ubuntu Server. If you follow these instructions carefully, you should have your photo gallery up and running quickly.

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!