How to Install PiGallery 2 on Arch Linux

PiGallery 2 is a self-hosted photo gallery, allowing you to store and access your photos from any device with a web browser. It is open source and can be installed on Arch Linux with these simple steps.

Prerequisites

Before we start, make sure your Arch Linux system is up-to-date and you have sudo privileges:

sudo pacman -Syu

Step 1: Install Dependencies

PiGallery 2 requires the following dependencies:

Install them using this command:

sudo pacman -S php php-gd php-exif apache imagemagick exiftool git

Once installed, it's recommended to restart Apache or Nginx:

sudo systemctl restart httpd.service
sudo systemctl restart nginx.service

Step 2: Clone PiGallery 2

Navigate to the directory where you want to install PiGallery 2 and clone the repository from GitHub:

cd /usr/share/webapps/
sudo git clone https://github.com/bpatrik/pigallery2.git

Step 3: Set Permissions

Change the ownership of the PiGallery 2 directory to the web server user so it can access and serve the files:

sudo chown -R http:http pigallery2

Step 4: Configure Apache or Nginx

PiGallery 2 can be run on either Apache or Nginx. Here are the steps for both web servers:

Apache

Create a new virtual host by editing the httpd-vhosts.conf file:

sudo nano /etc/httpd/conf/extra/httpd-vhosts.conf

Add the following lines:

<VirtualHost *:80>
    ServerName yourdomain.com
    DocumentRoot "/usr/share/webapps/pigallery2"
    <Directory "/usr/share/webapps/pigallery2">
        AllowOverride All
        Options FollowSymLinks
        Require all granted
    </Directory>
</VirtualHost>

Replace yourdomain.com with your domain or IP address. Save and close the file.

Enable the new virtual host:

sudo a2ensite yourdomain.com.conf

Reload Apache:

sudo systemctl reload httpd.service

Nginx

Create a new server block by editing the nginx.conf file:

sudo nano /etc/nginx/nginx.conf

Add the following lines:

server {
    listen 80;
    server_name yourdomain.com;
    root /usr/share/webapps/pigallery2;
    index index.php;
    location / {
        try_files $uri $uri/ /index.php?$args;
    }
    location ~ \.php$ {
        include fastcgi.conf;
        fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
    }
}

Replace yourdomain.com with your domain or IP address. Save and close the file.

Test the Nginx configuration:

sudo nginx -t

If no errors were found, reload Nginx:

sudo systemctl reload nginx.service

Step 5: Access PiGallery 2

Open a web browser and enter your domain or IP address to access PiGallery 2:

http://yourdomain.com

You will be prompted to create a new user and password. Once logged in, you can upload your photos and customize your gallery.

Congratulations! You have successfully installed PiGallery 2 on Arch Linux.

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!