Dealing With Gallery2 Errors

I recently ran into the following Gallery2 error while updating my website to work with suEXEC:

    * in modules/core/classes/GalleryTemplate.class
      at line 270 (GalleryCoreApi::error)

It turns out this somewhat cryptic error occurs because PHP no longer has permission to access the "g2data" directory (where Gallery keeps its data).

Since suEXEC forces PHP to run as your own username, rather than as the generic Apache user, it was unable to get access to the data files. The file permissions for the "g2data" directory still belonged to the "Apache" user.

The solution to this error is to make sure that your "g2data" directory is owned by the same user that PHP runs as. I accomplished this by opening a SSH connection to my server, making a copy of the "g2data" directory under ownership of my own username, and deleting the original "g2data" directory. After that, I renamed the new copy to "g2data", and everything was working again.

Posted by John on 2007-10-16