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.)
- Backup the entire Zenphoto site directory. Issuing a
cp -pr [zenphoto-dir] [zenphoto-backup]would suffice. - Backup the MySQL database. I use phpMyAdmin for this, so here are the steps for that tool:
- Select your Zenphoto database, then click the Export tab.
- Under the Export section, make sure all the tables are selected.
- 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.
- Select the checkbox for SQL Options > Data, but don’t select any of the sub-choices.
- Btw, all the remaining SQL Options should be deselected (unchecked).
- 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. - Hit the Go button. A backup
[db_name].sqlfile should happily appear in your computer’s download location (e.g., the desktop).
- Make sure you have a copy of the
.htaccessandrobots.txt(just in case) and your previouszp-core/zp-config.phpfiles. You’ll needzp-config.phpfor step 6. - Get the latest version of Zenphoto, but don’t upload it yet!
- 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!
- You’ll need to edit the new version of the configuration file with your database information. Looking at the old copy, change the following in
zp-core/zp-config.phpwith 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"")
- Now you can upload the new Zenphoto files, overwriting the appropriate old ones.
- To start the upgrade process, load the URL for
your.zenphoto.site. But if it doesn’t start properly, just loadyour.zenphoto.site/zenphoto/zp-core/setup.php, which is where it’d redirect to anyhow. - 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!
- 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).

3 comments
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.
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
albumsdirectory before copying stuff. Perhaps a future version of the upgrade process could do the checking and only createalbumsif one isn’t found?#6. Ah, so
setup.phpshould properly migrate the previouszp-config.phpsettings to the new one. Good to know!wrote the gallery2 to zenphoto (g2z) migrator here:
http://apps.ouwu.com/confluence/display/pb/Gallery2+to+ZenPhoto+Migrator
Submit a comment