Skip to content

Detailed Zenphoto upgrade steps

While the Zenphoto has great support, I’ve found the upgrade instructions slightly lacking for my own needs. So I’ve written up detailed steps for upgrading Zenphoto, which should work with version 1.1.6 and onward. (Unless the backend of the upgrading process changes significantly in the future, of course.)

  1. Backup the entire Zenphoto site directory. Issuing a cp -pr [zenphoto-dir] [zenphoto-backup] would suffice.
  2. Backup the MySQL database. I use phpMyAdmin for this, so here are the steps for that tool:
    1. Select your Zenphoto database, then click the Export tab.
    2. Under the Export section, make sure all the tables are selected.
    3. Under the SQL Options > Structure section, make sure the checkboxes for only Structure, Add DROP TABLE / DROP VIEW, Add AUTO_INCREMENT value, and Enclose table and field names with backquotes are selected.
    4. Select the checkbox for SQL Options > Data, but don’t select any of the sub-choices.
    5. Btw, all the remaining SQL Options should be deselected (unchecked).
    6. Select the Save as file checkbox, otherwise nothing will get backed up. 😉 Feel free to chose any of the compression choices, but I typically only use None.
    7. Hit the Go button. A backup [db_name].sql file should happily appear in your computer’s download location (e.g., the desktop).
  3. Make sure you have a copy of the .htaccess and robots.txt (just in case) and your previous zp-core/zp-config.php files. You’ll need zp-config.php for step 6.
  4. Get the latest version of Zenphoto, but don’t upload it yet!
  5. Unzip the new Zenphoto package and if you are upgrading, remove its albums folder. Otherwise, copying it over will clobber your existing albums and photos!
  6. You’ll need to edit the new version of the configuration file with your database information. Update: Actually, as of v1.2.x, you don’t need to manually edit zp-config.php; the installer will do it for you. However, do make a note of the settings since the installer will prompt you for them! Looking at the old copy, change the following in zp-core/zp-config.php with your own specific settings:
    • $conf['mysql_user'] = "your-mysql-username";
    • $conf['mysql_pass'] = "your-mysql-passwd";
    • $conf['mysql_host'] = "your-mysql-host-URL";
    • $conf['mysql_database'] = "your-zenphoto-db-name";
    • $conf['mysql_prefix'] = "your-zenphoto-db-prefix"; (If it has no prefix, just use the empty string "")
  7. Now you can upload the new Zenphoto files, overwriting the appropriate old ones.
  8. To start the upgrade process, load the URL for your.zenphoto.site. But if it doesn’t start properly, just load your.zenphoto.site/zenphoto/zp-core/setup.php, which is where it’d redirect to anyhow.
  9. At some point you’ll be prompted to login as the administrator, after which you should get the Go! button. Select your language from the dropdown menu, such as English (US), then hit Go!
  10. When you get the following message, it means that everything succeeded.

    About to update tables…
    Done with table update!

    You can now View your gallery, or administrate.

Troubleshooting

I get a 403: Forbidden error when I try to just load my Zenphoto site. The .htaccess needs to be readable by everyone in order to view, administrate or upgrade your Zenphoto site. Issuing chmod 644 .htaccess should do the trick. On a side note, I change the permissions for albums and cache directories from 777 to 755, because my hosting service runs the appropriate server processes as me, rather than another administrative user. Likewise, I change the uploaded images to 644, rather than 666.

I got as far as step 8 to run the upgrade script, but I get a blank page. Make sure you have edited zp-core/cp-config.php with your specific database settings (step 6) before you run the automatic upgrade.

I don’t get a login prompt, or the Go! button never appears at step 9 for me. Or, I get weird errors during the “About to update tables…” part of the upgrade. Try reloading your.zenphoto.site/zenphoto/zp-core/setup.php. Strangely, that seems to give it push in the right direction.

I get the page with Go!, but I also get an error that I need to upload the .htaccess which came with the new version. But I don’t want to clobber my special changes! You backed it up, right? (Step 3.) In which case, just upload the newer version per the Zenphoto instructions. After you have finished the upgrade, you can go back and edit .htaccess to further modify it.

Oh noes! Where did my robots.txt file go? Ah, you might’ve copied over the new Zenphoto directory to clobber the entire old one. What I do is select the contents of the new one and copy them over into the old one, so that files missing in the new package still persist. But restoring robots.txt is a snap if you already backed it up at step 3. 🙂

Extra. I want more control over hotlinking. How do I prevent everyone but allow a select few? For example, to allow access from your own domain, Google and cached searches, paste the following between the RewriteBase / and RewriteRule ^admin/?$ zp-core/admin.php [R,L] statements in the IfModule mod_rewrite.c section of the .htaccess file:

RewriteCond %{HTTP_REFERER} !mydomain\.com [NC]
RewriteCond %{HTTP_REFERER} !google\. [NC]
RewriteCond %{HTTP_REFERER} !search\?q=cache [NC]
RewriteCond %{HTTP_REFERER} !^$

Don’t forget to use your own domain name. This works when Full image protection uses Protected view with Disable hotlinking selected (located under Options > Image Display of the Zenphoto admin tools). Update (16 Sept 2009): I no longer seem to need to do this task as of version 1.2.6.

3 comments

  1. Stephen Billard wrote:

    This is a nice description.

    Some comments:
    #5. If copying an empty folder over an existing folder is removing all the contents of the existing folder there is someting wrong with your operating system. The albums folder in the distribution is empty.

    #6. It is really better to let setup.php do the zp-config.php editing. All these parameters can be entered there if they are not already correct.

    “Oh noes! Where did my robots.txt file go?”: There is only an example_robots.txt file in the distribution. But of course if you deleted your old robots.txt file you would certainly need to restore it.

    Thursday, 24 July 2008 at 9:51 am | Permalink
  2. sairuh wrote:

    Hi Stephen, thanks for the feedback.

    #5. I’m on Mac OS X, so copying a folder over a non-empty folder with the same name will erase the contents. However, I do get a prompt warning me about that, so I can cancel. Because I have accidentally disregarded such prompts in the past, I’ve just gotten into the safer habit of removing the newer albums directory before copying stuff. Perhaps a future version of the upgrade process could do the checking and only create albums if one isn’t found?

    #6. Ah, so setup.php should properly migrate the previous zp-config.php settings to the new one. Good to know!

    Thursday, 24 July 2008 at 8:41 pm | Permalink
  3. traviswu wrote:

    wrote the gallery2 to zenphoto (g2z) migrator here:
    http://apps.ouwu.com/confluence/display/pb/Gallery2+to+ZenPhoto+Migrator

    Wednesday, 6 August 2008 at 8:40 am | Permalink