The following instructions are specifically for installing Gallery 1.4.1 on a website hosted on a shared server at DreamHost. I created the original instructions from notes I took during a somewhat bumpy 1.3.3 install. If you follow these streamlined and updated notes that contain my many "lessons learned", your install should be much smoother than my first install.

I recently did a multisite install of Gallery2. Gallery2 comes with a very nice install wizard that does most of the installation work for you. I definitely recommend using Gallery 2 over 1.x, if you have a choice. There were a few subtleties in getting the instal to work the way I wanted, so I will try to write up my Gallery2 notes when I get a chance.

If you notice an error or missing info, I would appreciate it if you would let me know at robert AT wombatnation DOT com.

One very good piece of news for DreamHost clients is that Gallery releases starting with version support the version of ImageMagick that is installed on DreamHost servers. That will save you from having to mess with NetPBM.

Any text in bold should be replaced with your specific website domain name, user name, password, filenames, etc.

Download and Install Gallery

These notes used to have instructions for installing jhead. It should now already be installed on all DreamHost shared servers.

  1. Download Gallery (gallery-1.x.x.tar.gz) to your local machine
  2. FTP in binary mode the Gallery zipfile to the root dir of your website (You could have transferred the files directly to your DreamHost server with wget. I just can't break old habits.)
  3. Connect to your DreamHost server using ssh. On Windows, I use PuTTY. On Mac OS X, I use Fugu. On Linux, I use ssh on the command line, as Linus intended.
  4. cd domainname.com
  5. mkdir albums (I chose to put the albums dir outside of the gallery dir)
  6. chmod 775 albums
  7. tar -zxf gallery-1.x.x.tar.gz (Using the appropriate version numbers in the filename)
  8. Optional sanity check: Do an "ls gallery" to list the directory contents and verify that a directory called gallery was created under the root of the website and was populated with seemingly appropriate files and directories
  9. cd gallery
  10. mkdir tmp (I chose to put the tmp dir inside the gallery dir)
  11. chmod 777 tmp
  12. sh configure.sh

If everything went smoothly, you should see:

You are now in setup mode, which is *INSECURE*.  Your Gallery
installation can be configured by pointing your web browser
to the URL to 'setup' in this directory.

When you are done with your installation, don't forget to
run the secure.sh script!

    % sh secure.sh

Check Apache and PHP version

I used http://domainname.com/gallery/setup/phpinfo.php to determine that my DreamHost server had Apache 1.3.27 and PHP 4.3.5 installed at the time. This URL is accessible only when you have Gallery in setup mode.

Configure Gallery

Below are the required steps. You may also want to adjust some of the other settings at the same time. If this is your first time to install Gallery, I recommend sticking with just the required changes during the first pass. You can easily come back and change the other settings after you have gotten a basic Gallery install up and running.

  1. In a web browser, go to http://domainname.com/gallery/
  2. Click on "Start the configuration wizard" link
  3. The next page or two may have several "Warning: exec() has been disabled for security reasons in ..." lines
  4. You might get a warning about only part of netPBM being installed. This warning is not a problem, since we will use ImageMagick instead of NetPBM.
  5. Click "Next Page ->" button
  6. Gallery Title - Enter desired name for your gallery
  7. Admin password - Enter a password for the admin user in both text boxes
  8. Album directory - Set to /home/username/domainname.com/albums
  9. Temporary directory - Set to /home/username/domainname.com/gallery/tmp
  10. Graphics suite to use? - Change from NetPBM to ImageMagick
  11. Path to NetPBM - Delete the entry so that the textbox is empty (deletion required only for Gallery 1.3.3)
  12. Path to ImageMagick - Make sure it is /usr/bin
  13. Jhead EXIF Parser - Set to /usr/bin/jhead
  14. DreamHost Specific Note:If any of the paths has a directory name that starts with a period and appears between /home and /username, delete it. If DreamHost moves you to a new server, that bit will change and your Gallery install will stop working.
  15. Status code - Set to 0
  16. Click "Next Page ->" button

More of the "Warning: exec() has been disabled for security reasons in ..." lines may appear. Or, you may see lines like:

Error: albumDir: /home/username/domainname.com/albums exists, but is not writeable by the webserver user. Try:
chown -R dhapache /home/username/domainname.com/albums

or if that doesn't work:
chmod -R 775 /home/username/domainname.com/albums

Go to the gallery directory in an ssh client and add to the end of the gallery/.htaccess file the following line:

AddType php-cgi .php

Here are some simplified instructions for editing this file with the Emacs editor from within the gallery directory.

  1. emacs .htaccess
  2. Press the escape key and then press > (holding down the shift key if necessary) to go to the end of the file
  3. Enter on a new line the following text
    AddType php-cgi .php
  4. Press ctrl-x then press ctrl-s then press ctrl-x then press ctrl-c to save and exit emacs

That should get rid of the exec() warnings. However, it may cause two more warnings (Apache ignoring .htaccess and magic quotes enabled) to appear on the system check page if you go back to it.

  1. Leave all the settings as the built-in defaults the first time through. After you have verified that Gallery is up and running, you should rerun the configuration wizard if you want to customize these settings.
  2. Click "Next Page ->" button
  3. Review settings to make sure there were no errors or mistakes
  4. Click "Save Config" button and you should get a page saying "Your configuration has been successfully saved!"

Final Cleanup

  1. Switch back to your ssh client application
  2. Open the .htaccess file in a text editor like nano or emacs. When saving the Gallery config above, Gallery may have overwritten the AddType line in the gallery/.htaccess file. Versions 1.4.x are better behaved about this, but you should doublecheck anyway.
  3. If necessary, re-add: AddType php-cgi .php to the end of the .htaccess file after the lines that Gallery added
  4. sh secure.sh

Test Run

  1. Open a web browser
  2. Navigate to http://domainname.com/gallery/ to see main gallery window
  3. If you have problems, delete the domainname.com browser cookie named PHPSESSID
  4. Click on the login link and log in as admin

Final Notes

Everytime you re-run the configuration wizard on a version of Gallery older than 1.4, you will need to:

  1. Enter your admin password
  2. Delete the provided path for NetPBM (fixed in 1.3.4)
  3. Add back the "AddType php-cgi .php" line to .htaccess after saving the config changes

All these issues were fixed when I upgraded to version 1.4. All you need to remember is to run sh configure.sh to put Gallery in setup mode and then run sh secure.sh when you are done. However, a fellow DreamHoster reported that she still had to add back the "AddType" line to .htaccess when she installed 1.4.1, so I recommend that you check the .htaccess file contents to be sure they're correct.

Troubleshooting Tips I Learned the Hard Way

If you see the following error:

Warning: fopen(".../albums/an_album_name/album.dat.lock","a+")

this means that one or more files or directories in your albums directory were somehow made to be non-writeable. You can fix this with:

chmod -R 775 /home/username/domainname.com/albums

If you see an error message like:

Warning: open(/tmp/sess_429f50b0887ae0f19e4a078a53f87565, O_RDWR) failed: Permission denied (13) in /home/.blah/username/domainname.com/gallery/session.php on line 51

you have a stale PHPSESSID cookie. You need to delete it. If you use Mozilla for your web browser:

  1. From the Tools menu select Cookie Manager|Manage Stored Cookies
  2. Scroll down until you see the cookies for your website domain
  3. Select the cookie named PHPSESSID
  4. Make sure you do NOT have checked "Don't allow removed cookies to be reaccepted later"
  5. Click Remove and then click Close

If you use Mozilla Firefox:

  1. From the Tools menu select Options...
  2. Click the Privacy button and then click the + to the left of Cookies
  3. Click on Stored Cookies...
  4. Scroll down until you see the cookies for your website domain
  5. Select the cookie named PHPSESSID
  6. Make sure you do NOT have checked "Don't allow removed cookies to be reaccepted later"
  7. Click Remove Cookie and then click OK

If you unfortunately still use Internet Explorer, bring up the Internet Options window, select the Privacy tab, click Edit..., scroll down until you find the cookies for your website, select the PHPSESSID cookie for your site, click Remove, and then download either the Mozilla web browser or Mozilla Firefox. You'll be happy you did.