Howto Setup Photo Gallery with Piwigo in Fedora / Ubuntu / CentOS

Piwigo is a free and open source web based photo gallery software which is available under GNU General Public License. It is heavily developed and designed by an active community of developers and users. Piwigo is written in PHP language and uses MySQL database for storage. Piwigo is highly customizable as anyone is allowed to modify it according to their use, besides that it has its extensions freely available. It has a beautiful photo gallery in the frontend and very interactive dashboard making things easy to perform. Some of the main features of Piwigo are listed as follows.

  • It is easy to upload photos and videos with ftp, web uploads, android/iOS and desktop applications.
  • We can organize our photos with Albums.
  • It assures privacy on our Photos allowing us to decide who can see them.
  • It is highly customizable with its free themes and plugins available on the internet.
  • Piwigo is heavily localized by its active community all around the world making it available in many languages.
  • It has the ability to generate multiple size photos and enables us to add watermarks automatically.
  • The most important feature is that, it has statistics and management tools enabling us to manage our photo gallery.

Here are some easy steps on how we can install Piwigo online photo gallery in Fedora, Ubuntu and CentOS linux distributions.

1. Installing LAMP Stack

First of all, we'll install LAMP Stack in our linux machine which includes Apache web server, MySQL/MariaDB Database server and PHP modules. Here, in this tutorial, we'll be using MariaDB as its a complete free and open source software, fast and enhanced fork of MySQL. As the complete latest LAMP stack is available on the official repository of almost all linux distribution which includes Fedora, Ubuntu and CentOS, we'll simply install them using their default package manager respectively.

On Fedora 22

As dnf package manager is the default package manager of fedora 22, we'll simply run the following dnf command to install LAMP stack under sudo/root access.

# dnf install httpd mariadb mariadb-server php php-mysql php-gd ImageMagick unzip wget

On Fedora 21

As yum package manager is the default package manager of fedora 22, we'll simply run the following yum command.

# yum install httpd mariadb mariadb-server php php-mysql php-gd ImageMagick unzip wget

On Ubuntu 12.04/14.04/15.04

To install LAMP stack on Ubuntu machine, we'll need to run the following apt commands under sudo/root access.

# apt-get install apache2 mariadb-server php5 php5-mysql php5-gd imagemagick unzip wget

On CentOS 6/7

As we know the default package manager of centos is yum package manager, we'll need to run the following command to install it.

# yum install httpd mariadb mariadb-server php php-mysql php-gd ImageMagick unzip wget

2. Starting and Enabling Apache and MariaDB

We'll now start our apache web server and mariadb database server and configure it to start automatically in every system boot. To do so, we'll need to run the following command.

On SysVinit

If we have the release of linux distributions like CentOS 6.x , Ubuntu 12.04/14.04, running SysVinit installed in our machine then we'll need to run the following command to start apache and mariadb services.

On CentOS 6.x

# service httpd start
# service mariadb start
# chkconfig --levels 235 httpd on

On Ubuntu 12.04/14.04

# service apache2 start
# service mariadb start
# update-rc.d apache2 defaults

On Systemd

If we have latest release of linux distributions like Fedora 22, CentOS 7, Ubuntu 15.04 running systemd installed in our machine then we'll need to run the following command to start apache and mariadb services.

On Fedora 21/22/CentOS 7

# systemctl start httpd mariadb
# systemctl enable httpd mariadb

Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

On Ubuntu 15.04

# systemctl start apache2 mariadb
# systemctl enable apache2 mariadb

Created symlink from /etc/systemd/system/multi-user.target.wants/apache2.service to /usr/lib/systemd/system/apache2.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

3. Setting MariaDB root password

Next, we'll need to setup a password for our mariadb root user as we're installing it for the first time. To do so, we'll need to run the following command in a terminal.

# mysql_secure_installation

Note: Now, the script will ask us to enter the password for the database's root user but as we haven't set any password, we'll simply press enter. Then, we'll be asked to set a new password for the database's root user. Here we'll hit Y and enter our password for root of MariaDB. Then, we'll simply hit enter to set the default values for the further configurations.

....
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
...
installation should now be secure.

Thanks for using MariaDB!

4. Creating MariaDB Database for Piwigo

Next, we'll login to the MariaDB command prompt as root. To so do, we'll need to execute the following command.

# mysql -u root -p

Then, we'll be prompted to enter the password of root user of mariadb database. Here, we'll need to enter the password we'd set in the above step while configuring mariadb. After done, we'll be welcomed into the MariaDB command prompt environment.

We'll create the database for piwigo in our mariadb. To do so, we'll need to run the following command inside the mariadb command prompt environment.

> CREATE DATABASE piwigo_db;
> CREATE USER 'piwigo_user'@'localhost' IDENTIFIED BY 'P!W!g0_p1$$wor4';
> GRANT ALL PRIVILEGES ON piwigo_db.* TO 'piwigo_user'@'localhost';
> FLUSH PRIVILEGES;
> EXIT; Creating MariaDB Database

We’ve successfully created a database named piwigo_db with database user piwigo_user and its password as P!W!g0_p1$$wor4 .

Note: It is strongly recommended to replace the above variables as your requirement or desire as per the security issue.

5. Downloading Latest Piwigo

We'll now download and extract the latest release of Piwigo from its official download page. We'll get inside the /tmp folder and download the zipped package of the latest release of Piwigo and name it as piwigo-latest.zip . To do so, we'll need to run the following command in a terminal.

# cd /tmp/
# wget "http://piwigo.org/download/dlcounter.php?code=latest" -O piwigo-latest.zip

--2015-08-18 22:09:52-- http://piwigo.org/download/dlcounter.php?code=latest
Resolving piwigo.org (piwigo.org)... 87.98.147.22
Connecting to piwigo.org (piwigo.org)|87.98.147.22|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7233466 (6.9M) [application/zip] Saving to: 'piwigo-latest.zip'
piwigo-latest.zip 100%[=====================>] 6.90M 2.35MB/s in 2.9s
2015-08-18 22:09:55 (2.35 MB/s) - 'piwigo-latest.zip' saved [7233466/7233466]

After we have successfully downloaded the zipped package, we'll now simply extract it using unzip. To do so, we'll need to run the following command.

# unzip piwigo-latest.zip

Next, we'll gonna move the whole extracted folder to the webroot of our web server. As the default webroot of apache web server is /var/www/html/ , we'll simply move it into that folder by running the following command.

# mv piwigo /var/www/html/gallery

6. Changing Ownership

Now we'll change the ownership of the piwigo directory to apache so that the apache process owner will have full read and write access to the directory.

On Fedora/CentOS

If we are running Fedoro or CentOS or their derivatives, we'll need to run the following command to change the ownership of directory.

# chown apache: -R /var/www/html/gallery

On Ubuntu

In Ubuntu machine, we'll need to replace apache to www-data in the above command and execute as shown below.

# chown www-data: /var/www/html/gallery

7. Allowing Firewall

If we have firewall programs like iptables, firewalld running, we'll need to allow http port 80 in order to make our web server and website accessible remotely from the internet.

On Iptables

In the linux distibutions like Fedora 21, CentOS 6.x, Ubuntu 12.04/14.04 , iptables is used as the default firewall program. To allow port 80 from iptables, we'll need to run the following command.

# iptables -I INPUT -p tcp --dport 80 -j ACCEPT

Then, in order to apply the changes permanently even after the reboot, we'll need to save the configuration by running the following command.

# service iptables save

On Firewalld

Firewalld is used as the default firewall program in the latest releases of linux distributions like Fedora 22, CentOS 7, Ubuntu 15.04 running systemd. So, to allow http port 80, we'll need to run the following command.

# firewall-cmd --permanent --zone=public --add-service=http

To apply the changes made above, we'll need to reload our firewalld, by running the below command.

# firewall-cmd --reload

9. Allowing SELinux

If we are running Fedora 21/22 or CentOS 7 in our machine, we've SELinux security feature enabled by default. So, in order to make SELinux allow our piwigo installation to work, we'll need to run the following command.

# cd /var/www/html/gallery/

#  chcon -vR --type=httpd_sys_rw_content_t .

8. Web Installation

Finally after such a hard work, we'll be able to navigate to our Piwigo web interface by pointing our browser to http://ip-address/gallery or http://domain.com/gallery according to our configuration.

Configuring Piwigo

Here, we need to enter the required database configuration that we had set in the above step while creating database in MariaDB. In this tutorial, we've user, password and database name as piwigo_user, P!W!g0_p1$$wor4 and piwigo_db respectively. Then, we'll need to enter the administration configuration that we'll need in order to login to the Administrative Panel of Piwigo. After done, we'll click on Start Installation to continue further.

Piwigo Welcome Page

After the installation has been finished, we'll gonna click on Start the Tour to login into our Piwigo Admin panel. Then, we'll see our Admin panel as shown below. If we wanna learn more about Piwigo gallery, we can read the instructions shown in small dialogue window.

Piwigo Admin Panel

To upload an image, we'll need to click on Add under Photos which lies on the left sidebar as shown in the figure.

Piwigo Gallery Homepage

After uploading our images, it will be loaded in our Piwigo Photo Gallery. We can easily customize our photo gallery using different options available in our admin panel.

Known Issue and Fix

Error

If we see the following error on the top of our Piwigo Gallery Admin panel, we can make sure that the date.timezone variable is disabled in our PHP configuration.

date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.

Fix

To fix the above error, we'll need to specify a date.timezone variable in our PHP configuration file. To do so, we'll need to open it using a text editor.

# nano /etc/php.ini

After that, we'll need to find for the line where date.timezone variable in assigned. Here, we'll need to specify the timezone that we want to set to our application.

date.timezone =America/Los_Angeles

Conclusion

Piwigo is an excellent photo gallery application which has made pretty easy for people to host their own gallery in the internet. The most awesome thing is that, Piwigo is very easy to setup and customize according to our desire and requirement. It has beautiful web interface which is pretty responsive. Piwigo is highly extensible as there are hundreds of powerful plugins and extensions. There are also several hosting companies which provides hosting services to Piwigo. If we have LAMP stack installed or have a shared hosting, we can simply install Piwigo with its NetInstall PHP script . It is also available on Softaculous web app installer making its installation far easier with a single click. So, if you have any queries, suggestions, comments, please do comment below so that we can improve our contents and website. Thanks!

About Arun Pyasi

Linux Enthusiast geek and Web Developer who loves Free and Open Source Software (FOSS). He is a FOSS activist who loves technology, hacking, blogging, travelling, research and development. He is the Founder/Lead Developer of Chitwanix OS.

Author Archive Page

Have anything to say?

Your email address will not be published. Required fields are marked *

All comments are subject to moderation.

1 Comment

  1. Amazing post! I had many issues with apache permission and others things while trying to install Piwingo on CentOS 7, and you article helped me a lot, and finally it's worked! Tks man!