[Suggestion] Single File PHP Gallery


Single File PHP Gallery is a web gallery in one single PHP file. All you have to do is copy the script to any directory containing images to make a gallery. Sub directories will be sub galleries. Thumbnails for images and directories are generated automatically.
More info: http://sye.dk/sfpg/


cd /tmp
wget http://sye.dk/sfpg/Single_File_PHP_Gallery_4.5.7.zip
mkdir /var/www/gallery
unzip Single_File_PHP_Gallery_4.5.7.zip -d /var/www/gallery

You must change line 22 to ‘define(‘SECURITY_PHRASE’, ‘true’);’ else the gallery won’t load.

You need PHP 5 and php_gd (not installed by default, apt-get install php5-gd) installed.

Demo: http://s6.pilovali.nl/gallery/

This looks great, awesome find.

My only concern is the end user and /var/www permissions. eg: user makes a folder /var/www/moo , user will need to chown -R www-data:www-data etc. However, i could put this in the online documentation.

https://github.com/Fourdee/DietPi/issues/91 :slight_smile:

You don’t need to do that. If you want to make a new folder inside gallery/ (folder = album) it does not need special rights.
There is only one folder that needs chown’ed, and that is ‘_sfpg_data’, it contains the thumbnails, EXIF data and cache, so it must be writeable for the webserver.


I’ll get this added for next release, then I really must start work on the Email stack/server for dietpi-software :slight_smile:.

Spot on. We have to create the _sfpg_data dir, then set permissions.

Once LASP is installed:

wget http://sye.dk/sfpg/Single_File_PHP_Gallery_4.5.7.zip -O package.zip
unzip package.zip -d /var/www/gallery
rm package.zip

#Get test images
mkdir -p /var/www/gallery/DietPi
wget http://dietpi.com/images/dietpi-logo_256.png -O /var/www/gallery/DietPi/logo_256.png
wget http://dietpi.com/images/dietpi-logo_150.png -O /var/www/gallery/DietPi/logo_150.png
#mkdir -p /var/www/gallery/Tr-Zero

#permissions for cache/thumbnail/database
mkdir -p /var/www/gallery/_sfpg_data
chown -R www-data:www-data /var/www/gallery/_sfpg_data
chmod -R 775 /var/www/gallery/_sfpg_data

#enable (Some type of security trigger)
sed -i "/define('SECURITY_PHRASE'/c\define('SECURITY_PHRASE', 'true');" /var/www/gallery/index.php

Keep in mind that php5-gd needs to be installed and after that, Apache2 needs to restart. It was not installed by default, atleast not for me.

If you want to test if the installation is succesful and if the gallery runs correctly, run this PHP script.

Yep, seems php5-gd is needed for thumbnails.

Looking good:

Single File PHP Gallery TEST FILE 1.5.0
1: PHP version: 5.6.13-0+deb8u1. ok.
2: PHP Memory limit: 128M
3: Checking required functions: All required functions found.
4: Checking GD version: GD version: 2.1.1-dev
5: Checking image type support: Support for: GIF JPG/JPEG PNG 
6: Testing to find maximum image size handling: (1024²)(2048²)(4096²)(8192²)(16384²)(!32768²)

Did you add php5-gd to the installation LASP/LAMP installation?

Nope, this is installed alongside the Php gallery.

Available in DietPi v97: https://dietpi.com/forum/t/dietpi-software-details-for-all-installation-options/22/35