How To Share Your Photos For Free From Your Home Server Using Ubuntu 12.04 LTS And phpAlbum

If you would like to share your photos with family and friends from your own home server rather than posting onto some social networking site then perhaps this is the how-to for you.

phpAlbum is an easy to use photosharing website that you can host yourself and use it to easily manage, view and selectively share your own photo collection with freinds, family, and the world. It's all free and you retain full ownership over the whole system. A completed system can be seen at the projects home page http://www.phpalbum.net/demo4/main.php?cmd=album
The phpAlbum homepage is here http://www.phpalbum.net/

 

Prerequisites

To follow this tutorial you will need:

  1. A PC with ubuntu 12.04 LTS running LAMP
  2. Your own web address
  3. Forward port 80 from your router to your ubuntu server
  4. SAMBA/SWAT running on your server.

Each of these can be done for free by following each of the three nice tutorials linked below.

  1. http://www.ubuntugeek.com/step-by-step-ubuntu-12-04-precise-lamp-server-setup.html
  2. https://www.howtoforge.com/how-to-install-no-ip2-on-ubuntu-12.04-lts-in-order-to-host-servers-on-a-dynamic-ip-address
  3. https://www.howtoforge.com/How-to-forward-ports-to-your-ubuntu-12.04-LTS-LAMP-server
  4. http://askubuntu.com/questions/196272/how-to-install-and-configure-swat-in-ubuntu-server-12-04

NB: The very last step of (4) is to login as a "member of the admin group" - you can ignore this and login to SWAT later when instructed to do so in this tutorial when you actually come to use it.

O.K. I will assume you followed these 4 guides and you now have an ubuntu 12.04 LAMP system running SAMBA/SWAT and a no-ip website address with port 80 forwarded to the ubuntu server.

 

Create shared folders for photos

From an ubuntu terminal

Create a password for the root user for easy login to SWAT

sudo passwd

Enter and repeat your new <root user password> I tend to use  my <ubuntu user password> for simplicity. You may enter some new password for the ubuntu root user for added security but please note down the <root user password> as you will need it to log in to SWAT later.

For some reason the libpam-smbpass is now broken which, in turn, breaks SWAT. We can hack a fix by disabling libpam-smbpass with

sudo apt-get remove libpam-smbpass

Create a Samba user. Please note you need to exchange <ubuntu username> for your own ubuntu username.

 sudo smbpasswd -a <ubuntu username>

Enter and repeat your new <SAMBA user password> Again I tend to use  my <ubuntu user password>  for simplicity. You may enter some new password for SAMBA for added security but please note down the <SAMBA user password> as you will need it to log in to the shared directories later.

Reload the SWAT-server software with

sudo dpkg-reconfigure xinetd

Create your photos directory and a download directory and give them quite permissive permissions so anyone can access the folders on your network.

sudo mkdir ~/photos
sudo chmod 777 ~/photos
sudo mkdir ~/downloads
sudo chmod 777 ~/downloads

The permissions are set with the 777 code and it means that anyone with access to the system can read, edit, and run the files contained within. You could set more restrictive permissions here but I prefer easy access to my media folders.

On a web browser go to http://<Ubuntu server hostname>:901
eg: http://ubuntuserver:901
login with user name: "root" and your <root user password>

Click on the shares box at the top
Now click "create share"
Enter the following into their respective boxes. Please remember to exchange <ubuntu username> to your own ubuntu username.

path:        /home/<ubuntu username>/photos
valid users:    <ubuntu username>
read only:    no
available:    yes

Now click commit changes
Now click advanced and set all the "masks" to 0777
Now click "commit changes" again

Now click "basic" and "create share"
Repeat the process for your "downloads" folder
You should now see your ubuntu server on the network and have access to the two shared folders you created provided you remember the <SAMBA user password> you set.
Again please note this is quite permissive and gives everyone on the network easy access to the music and downloads folder provided they know the <SAMBA user password> when they try to access the folders.

Now you are ready to download and install phpAlbum. At this point i like to start the copying of my photos over to the shared photos folder as this will take some time. Hopefully it will be done by the time I'm done installing phpAlbum.

 

Download and install phpAlbum

In your teminal enter

cd ~/downloads
wget http://www.phpalbum.net/files/phpAlbum_v0.4.1.16.zip

You may also like too go to the phpalbum webiste and makesure you are getting the latest version. In a web browser go to http://www.phpalbum.net/dw Just right click on the download button and paste the result into the wget line and adjust the version numbers in subsiquent commands to match.

Instead of the wget command you could also download the latest version from your browser and tehn copy it over the netwrk to your shared downloads folder on the ubuntu machine. (This is why we added the downloads folder in the shared folder part).

Install the unzip program

 sudo apt-get install unzip

Unzip the archive to your source directory

 sudo unzip ~/downloads/phpAlbum_v0.4.1.16.zip -d /usr/local/src/www

The rest of this how to were based on the instructions at  http://www.phpalbum.net/node/443

Create a working config file

sudo cp /usr/local/src/www/phpAlbum_v0.4.1.16/config_change_it.php /usr/local/src/www/phpAlbum_v0.4.1.16/config.php

Edit that file using the "nano" editor

sudo nano /usr/local/src/www/phpAlbum_v0.4.1.16/config.php

Go to the bottom of the file that just opened and change the following line

$data_dir="data/";

To instead read

$data_dir="/data_<random string of digits>/";

Where <random string of digits> is a random string of digits like xyz34jk Except make it your own random string and note it down for later. The line should look something like

$data_dir="data_xyz34jk/";

Now you can quit and save the file from nano. use ctrl-x to quit and hit Y when asked to save the file.

Add a symlink from the webserver to your new phpAlbum installation

cd /var/www/
sudo ln -s /usr/local/src/www/phpAlbum_v0.4.1.16 phpAlbum

And just because people often leave out the capital A we'll make a second link all lowercase

 sudo ln -s phpAlbum phpalbum

Doing it this way allows us to move websites around, rename them, and get newer versions of the websites later with ease simply by dropping them into the source folder then changing our symbolic links.

Remembering that random string of digits we will create two new folders to act as storage and cache for phpAlbum to use

sudo mkdir /data_xyz34jk
sudo mkdir /cache_xyz34jk
sudo chown www-data /data_xyz34jk
sudo chown www-data /cache_xyz34jk
sudo chmod 0700 /data_xyz34jk
sudo chmod 0700 /cache_xyz34jk

Replacing xyz34jk with your random string of digits of course

Now let's add a symlink to link your shared photos folder ie

cd /var/www/phpAlbum
sudo ln -s ~/photos photos_xyz34jk

Now we're ready to login and start administering the photo sharing website.

 

Set Up phpAlbum

If you are security conscious you should probably only login to the admin part for the website when you are at home using a local address rather than the external no-ip address.
To improve the security you can make the symbolic link from inside a secure https folder but setting that up is outside the scope of this how to.

In a web browser (from inside the home network) go to
http://<Ubuntu server hostname>/phpAlbum

Click login at the top right and login with
user:admin
pass:admin

Now click setup at the top right
Change your admin password to something other than admin and remember it or you will have to delete and reinstall the unzipped phpAlbum folder

You do need to add email but not your home page if you dont want to.
leave super user checked and click "save configuration"

Now click main setup on the top left
enter the photos_<string of random digits>/ into the album directory box and
enter the /cache_<string of random digits>/ into the cache directory box
obviously swap out <random string of digits> for YOUR random string of digits
note carefully the lack of preceeding slash in the first box and the presence of the trailing slashes in both boxes.
 
Click "Save configuration"

Now click galleries on the left
Now click scan directories now
The php code will scan the photos directory and add a new gallery for each folder that contains photos. You can set visibility options for each gallery here.
Then if you want you can set vibility levels for individual photos in a gallery by selecting the gallery here then clicking "pictures" on the left and choosing individual options there.

Thats it you should be up and running now.
Have a look around the site, you can create users with different permission levels and edit picture parameters and send ecard invites and a whole bunch of stuff.

Once you are done with the administrator back end you can go back to the front page and see the results by clicking the green "<<< Album" button

Enjoy your photo sharing.

Share this page:

1 Comment(s)