Piwigo is a free, open-source, web-based photo gallery application that allows you to upload your photos and videos via FTP, web uploads, and desktop applications. It is written in PHP and uses MySQL as a database backend. Piwigo is especially useful for a photographer who wants to upload their photographs to the web and show them to their client. Piwigo allows you to customize per your needs using built-in extensions.
In this tutorial, we will show you how to install Piwigo Photo Gallery on Ubuntu 20.04.
Step 1 – Install LAMP Server
First, you will need to install the Apache web server, MariaDB, PHP and other PHP extensions to your server. You can install all of them with the following command:
apt-get install apache2 mariadb-server php libapache2-mod-php php-common php-mbstring php- xmlrpc php-gd php-xml php-intl php-mysql php-cli php php-ldap php-zip php-curl unzip git -y
Once all the packages are installed, edit the php.ini file and tweak some settings to recommended values:
nano /etc/php/7.4/apache2/php.ini
Change the following lines:
memory_limit = 256M upload_max_filesize = 100M date.timezone = America/Chicago
Save and close the file, then restart the Apache service to apply the configuration.
systemctl restart apache2
Step 2 – Create a Database for Piwigo
Piwigo uses MySQL or MariaDB as a database backend, so you will need to create a database and user for Piwigo.
First, log in to MySQL with the following command:
mysql
Once logged in, create a database and user with the following command:
CREATE DATABASE piwigo; CREATE USER 'piwigo'@'localhost' IDENTIFIED BY 'password';
Next, grant all the privileges to the piwigo database with the following command:
GRANT ALL ON piwigo.* TO 'piwigo'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
Next, flush the privileges and exit from the MySQL shell with the following command:
FLUSH PRIVILEGES; EXIT;
Step 3 – Install Piwigo
First, download the latest version of Piwigo from their official website using the following command:
curl -o piwigo.zip http://piwigo.org/download/dlcounter.php?code=latest
Once the download is completed, unzip the downloaded file with the following command:
unzip piwigo.zip
Next, move the extracted directory to the Apache web root directory:
mv piwigo /var/www/html/piwigo
Next, set proper permissions and ownership with the following command:
chown -R www-data:www-data /var/www/html/piwigo/ chmod -R 777 /var/www/html/piwigo/
Step 4 – Configure Apache for Piwigo
Next, you will need to create an Apache virtual host configuration file for Piwigo. You can create it with the following command:
nano /etc/apache2/sites-available/piwigo.conf
Add the following lines:
<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /var/www/html/piwigo ServerName piwigo.example.com <Directory /var/www/html/piwigo/> Options +FollowSymlinks AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
Save and close the file, then enable the Piwigo virtual host and Apache rewrite module with the following command:
a2ensite piwigo.conf a2enmod rewrite
Finally, restart the Apache service using the following command:
systemctl restart apache2
Step 5 – Access Piwigo
Now, open your web browser and type the URL http://piwigo.example.com. You will be redirected to the Piwigo setup page:
Provide your database details and admin user information and click on the Start installation button. Once the installation has been completed successfully, you should see the following page:
Now, click on the Visit the gallery. You should see the Piwigo dashboard in the following page:
From here, you can add your photo easily or click on “I will find my way by myself.” You should see the following page:
Conclusion
Congratulations! You have successfully installed and configured Piwigo photo gallery on Ubuntu 20.04. You can now upload your photos and access them over the Internet easily – give it a try with VPS hosting from Atlantic.Net!