# \[Suggestion\] Single File PHP Gallery

**URL:** https://dietpi.com/forum/t/suggestion-single-file-php-gallery/121
**Category:** General Discussion
**Created:** [14 October 2015 08:04 UTC](https://dietpi.com/forum/t/suggestion-single-file-php-gallery/121 "2015-10-14T08:04:51Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Pilovali](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/p/c4cdca/32.png) [@Pilovali](https://dietpi.com/forum/u/Pilovali)
#### Post date: [14 October 2015 08:04 UTC](https://dietpi.com/forum/t/suggestion-single-file-php-gallery/121/1 "2015-10-14T08:04:51Z")

</div>

Hello,

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/](http://sye.dk/sfpg/)

Installation:

```nohighlight
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/](http://s6.pilovali.nl/gallery/)

---

<div class="post-metadata">

### Author: ![Fourdee](https://dietpi.com/forum/user_avatar/dietpi.com/fourdee/32/11_2.png) [@Fourdee](https://dietpi.com/forum/u/Fourdee)
#### Post date: [14 October 2015 11:49 UTC](https://dietpi.com/forum/t/suggestion-single-file-php-gallery/121/2 "2015-10-14T11:49:48Z")

</div>

> [@Pilovali](#):
>
> Hello,
> 
> 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: [Single File PHP Gallery 4.11.0](http://sye.dk/sfpg/)
> 
> Installation:
> 
> ```plaintext
> 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/](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.

---

<div class="post-metadata">

### Author: ![Fourdee](https://dietpi.com/forum/user_avatar/dietpi.com/fourdee/32/11_2.png) [@Fourdee](https://dietpi.com/forum/u/Fourdee)
#### Post date: [14 October 2015 11:50 UTC](https://dietpi.com/forum/t/suggestion-single-file-php-gallery/121/3 "2015-10-14T11:50:43Z")

</div>

[https://github.com/Fourdee/DietPi/issues/91](https://github.com/Fourdee/DietPi/issues/91) 🙂

---

<div class="post-metadata">

### Author: ![Pilovali](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/p/c4cdca/32.png) [@Pilovali](https://dietpi.com/forum/u/Pilovali)
#### Post date: [14 October 2015 12:17 UTC](https://dietpi.com/forum/t/suggestion-single-file-php-gallery/121/4 "2015-10-14T12:17:20Z")

</div>

> [@Fourdee](#):
>
> 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.

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.

---

<div class="post-metadata">

### Author: ![Fourdee](https://dietpi.com/forum/user_avatar/dietpi.com/fourdee/32/11_2.png) [@Fourdee](https://dietpi.com/forum/u/Fourdee)
#### Post date: [14 October 2015 18:31 UTC](https://dietpi.com/forum/t/suggestion-single-file-php-gallery/121/5 "2015-10-14T18:31:07Z")

</div>

> [@Pilovali](#):
>
> 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.

Awesome!

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

---

<div class="post-metadata">

### Author: ![Fourdee](https://dietpi.com/forum/user_avatar/dietpi.com/fourdee/32/11_2.png) [@Fourdee](https://dietpi.com/forum/u/Fourdee)
#### Post date: [15 October 2015 13:11 UTC](https://dietpi.com/forum/t/suggestion-single-file-php-gallery/121/6 "2015-10-15T13:11:48Z")

</div>

> [@Pilovali](#):
>
> 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.

Spot on. We have to create the \_sfpg\_data dir, then set permissions.

Once LASP is installed:

```plaintext
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

```

---

<div class="post-metadata">

### Author: ![Pilovali](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/p/c4cdca/32.png) [@Pilovali](https://dietpi.com/forum/u/Pilovali)
#### Post date: [15 October 2015 13:32 UTC](https://dietpi.com/forum/t/suggestion-single-file-php-gallery/121/7 "2015-10-15T13:32:49Z")

</div>

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](https://sye.dk/sfpg/sfpg_test_1.5.0.zip) PHP script.

---

<div class="post-metadata">

### Author: ![Fourdee](https://dietpi.com/forum/user_avatar/dietpi.com/fourdee/32/11_2.png) [@Fourdee](https://dietpi.com/forum/u/Fourdee)
#### Post date: [15 October 2015 13:55 UTC](https://dietpi.com/forum/t/suggestion-single-file-php-gallery/121/8 "2015-10-15T13:55:04Z")

</div>

> [@Pilovali](#):
>
> 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.

Yep, seems php5-gd is needed for thumbnails.

> [@Pilovali](#):
>
> If you want to test if the installation is succesful and if the gallery runs correctly, run [this](https://sye.dk/sfpg/sfpg_test_1.5.0.zip) PHP script.

Looking good:

```plaintext
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²)

```

---

<div class="post-metadata">

### Author: ![Pilovali](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/p/c4cdca/32.png) [@Pilovali](https://dietpi.com/forum/u/Pilovali)
#### Post date: [15 October 2015 13:58 UTC](https://dietpi.com/forum/t/suggestion-single-file-php-gallery/121/9 "2015-10-15T13:58:41Z")

</div>

> [@Fourdee](#):
>
> Yep, seems php5-gd is needed for thumbnails.

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

---

<div class="post-metadata">

### Author: ![Fourdee](https://dietpi.com/forum/user_avatar/dietpi.com/fourdee/32/11_2.png) [@Fourdee](https://dietpi.com/forum/u/Fourdee)
#### Post date: [15 October 2015 14:42 UTC](https://dietpi.com/forum/t/suggestion-single-file-php-gallery/121/10 "2015-10-15T14:42:31Z")

</div>

> [@Pilovali](#):
>
> Did you add php5-gd to the installation LASP/LAMP installation?

Nope, this is installed alongside the Php gallery.

---

<div class="post-metadata">

### Author: ![Fourdee](https://dietpi.com/forum/user_avatar/dietpi.com/fourdee/32/11_2.png) [@Fourdee](https://dietpi.com/forum/u/Fourdee)
#### Post date: [15 October 2015 14:45 UTC](https://dietpi.com/forum/t/suggestion-single-file-php-gallery/121/11 "2015-10-15T14:45:17Z")

</div>

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