Gallery

Gallery is a free, robust, and popular web-based software product that lets you manage photos on a website. It uses PHP and is available as a one-click install from the the Goodies tab of your Control Panel. The latest branch is version 2 (commonly refered to as G2 or Gallery2) which boasts a database (mysql) backend and extensive code review. Gallery 2 is still in its early releases but has been very useable for some time. Planned for the next releases are performance improvements among its new features. http://gallery.menalto.com/

Tips and Tricks

 * Panel: How Do I Install Gallery 2.x at Dreamhost?
 * Installing FFmpeg for movie thumbnail support
 * Using the external image block feature
 * Gallery Image Album Troubleshooting

=Problems=

Gallery on DreamHost issues
You may find that generating thumbnails/resized images will be slow or will not even complete. This is caused by locking over NFS. Gallery2 uses flock which does not work (and is not meant) for NFS. You should switch Gallery2 to database-based file locking by going into Site Admin -> General. You will find a locking mechanism dropdown box at the bottom of the page; just change it from "File" (the default) to "Database."

(Note from Desean: The above is no longer true for new servers on the homie cluster. Verified by Phiya C from the DreamHost Support Team on 14 Dec 2008. Quoting Phiya: "The server is no longer on NFS and is localized disk storage as it's on the homie cluster.". This should also be true for new servers moving forward.)

You may find that large (20MB+) MOV files cannot have a thumbnail generated in Gallery2. Try moving NetPBM to the top priority of the image toolkits.

Problems with large Galleries
Large galleries with 5000+ images (especially if being crawled by search engine spiders) may draw excessive processor power and trigger an alert with Dreamhost. This can be fixed by either denying bots with a robots.txt file or asking them to delay between page loads. Not all spiders respect the robots.txt, so denying their ip's (or ranges) in the .htaccess file may be necessary.

I also found that increasing PHP's memory_limit setting from the default of 8M to 16M (or even 24M) helped a great deal with thumbnail/resized image generation. ImageMagick's convert processes were taking a long time to run, or even just timing out altogether. I'm working with large photos taken with an 8 megapixel digital camera, so they're about 3-4 MB each. I haven't yet tried with GD, but if the problem persists, that's next. Try the link below for more information:

Gallery2 Forum Link


 * Can anyone verify that changing memory_limit actually works as described here: PHP.ini


 * According to support, it is not possible to change memory_limit in any of DH's shared hosting.

Common .htaccess problem with Gallery 2
For those that are having issues with Gallery breaking after setting up a .htaccess file via the Panel:

Quick info (my ticket and my solution)

I just set up a brand-new gallery2 site using the one click, got it up   and running fine. As soon as I enabled the ".htaccess" for the "gallery" subdirectory, the whole site broke.. it looks like the rewrite module busted, as it is having trouble finding the image directories. Removing the htaccess setting from the panel and verifying that it was removed from the website did not help.. The website is still broken :(   I even removed the entire website + database and did a reinstall from    scratch. The gallery website works just fine until you enable a    password on the http://site/gallery subdirectory.. then it breaks and    does not seem to repair. The html works but all the image    redirections are broken.

Since other users are having this problem, I've found the solution. Users need to make sure the "URL Rewrite" module is *deactivated* before dropping in a htaccess file. The problem is that the dreamhost script overwrites the .htaccess file, which already contains some rewrites for the gallery application. Once those rewrites are gone, the application breaks. If the Dreamhost script could insert the htaccess password information at the top of the htaccess file, it would probably fix things. If for some reason you can't log into your admin settings (or you   dropped the .htaccess file before you turned off URL rewrite) then go to this link to directly modify your modules. (assuming you installed   it to "gallery") http://your.site.com/gallery/main.php? g2_view=core.SiteAdmin&g2_subView=core.AdminModules&g2_navId=x8c473768

After you have the module deactivated and the site like you want it, go backto the modules settings and reconfigure the URL Rewrite module. Then reactivate it and all will be well

Installation: output_buffering warning
When installing you get this message:

Warning: Output buffering is enabled in your php by the output_buffering parameter(s) in php.ini. Gallery can function with this setting - downloading files is even faster - but Gallery might be    unable to serve large files (e.g. large videos) and run into the memory limit. Also, some features like the progress bars might not work correctly if output buffering is enabled unless ini_set is allowed.

To fix this, you have to configure a custom php.ini and php.cgi file in your home directory. Using only your own php.ini file will result in exec to fail and the Imagemagik binary to stop working. There is an excellent guide to do this at Advanced PHP configuration. While some rudimentary knowledge of UNIX and the shell is required, a relative beginner should be able to tackle it without much difficulty.

Once you go through that procedure, edit the ~/PHP5/update-php.php file and find the following line

output_buffering = 0

and change it to

output_buffering = off

Run the update-php.sh file again and the problem is solved!

Installation: Install Other Modules
You will also get the following warnings, indicating that configuration is necessary:

* The Dcraw module was installed, but needs configuration to be activated * The Ffmpeg module was installed, but needs configuration to be activated * The ImageMagick module was installed, but needs configuration to be activated * The Nokia Image Upload module was installed, but needs configuration to be activated * The URL Rewrite module was installed, but needs configuration to be activated

To configure these, in Gallery, go to Site Admin (top bar, at right), then in the left column (Admin Options -> Gallery), click on Plugins. You will then need to Configure, then Activate each plugin. These all work except for Dcraw, which is not installed as of December 2008.

Dcraw can be installed into your (shell account) directory; you may need to turn off output buffering to deal with large files.

Can I Upgrade Gallery from 1.x to 2 using the DH 1 click install?
If you previously had Gallery 1.x and would like upgrade to 2 it is possible to import your old albums into the new version
 * http://codex.gallery2.org/index.php/Gallery2:FAQ#Can_I_update_from_G1_-.3E_G2.3F


 * It doesn't appear that the 1 click install supports this module but installing from source works great.
 * The one-click install can't be used to upgrade directly, but it can be used to install Gallery 2 separately, then you can use the import utility to import your albums from Gallery 1. You will likely be better off importing albums a few at a time, rather than importing them all at once. This is especially a good idea considering G2 is very different, and you may find you like G1 better! --Steph

Updating to other version
Sometimes when you update to Gallery 2.2 and you go to the Plugins Section in the Administration Page you only get a white page. First of all you need to activate debug mode in Gallery2. To do this you need to edit the config.php file in you gallery2 directory and write this lines:

ini_set('display_errors', 1); $gallery->setDebug('buffered');

After, when you go to the Plugins Section you get the following warning:

Fatal error: Class 'GalleryStatus' not found in ... "module_name"

The solution (inspired by this thread) is to remove the directory of module_name located insides your_gallery/module directory. You can get multiple errors corresponding to multiple modules, all need to be removed.

Moving an Existing Gallery Site Onto Dreamhost
First off, it's a pain but it can be done. Here are the steps I had to follow: ''Optional but recommended: Clean up any spam comments you may have on your old Gallery. I had over 40,000 which bloated my database up to over 140 megs! The easiest way to clean this up if you don't care about your "regular" comments is to just completely uninstall and delete the Comment plugin and then re-install it.''


 * 1) Backup the MySQL database on the old server.
 * 2) Using phpMyAdmin, click into the Gallery database you currently use
 * 3) Click Export at the top
 * 4) Make sure all tables are selected and that the type of export selected is "SQL"
 * 5) Refer to the Gallery support site to get the specific options you want to select on the right hand side
 * 6) Check the "Save as file" box and click "Go" - save this .sql file somewhere so you can upload it later.
 * 7) Backup the MySQL database on the old server!
 * 8) Backup the MySQL database on the old server!!
 * 9) If your old Gallery is not the exact same version as the one Dreamhost loaded for you then you must upgrade it first.
 * 10) Just follow the steps the Gallery webpage gives you for upgrading to the right version.
 * 11) After it is on the right version I suggest you uninstall all of the plugins you possibly can from the Site Admin -> Plugins page.  This will make things easier down the road.
 * 12) When you're done and sure everything still works on the old host follow steps 1 through 3 again.
 * 13) Backup the (blank) MySQL database on Dreamhost just to play it safe.
 * 14) Find your current g2data directory and upload all the contents to your new Dreamhost g2data directory (in your FTP structure it is usually something like "DomainName_gallery_g2data").
 * 15) Upload your .sql database backup to your FTP account.
 * 16) SSH into your Dreamhost account (you may need to change your account type from plain old FTP to a Shell account first)
 * 17) To convert your account log into the Dreamhost Panel -> Users -> Manage Users
 * 18) Edit the user you wish to convert
 * 19) Change the User Account Type from FTP account to Shell account of type /bin/bash and click Save Changes at the bottom
 * 20) Your next step is to import the backed up tables from your old host into the new blank-ish MySQL database that Dreamhost created for you
 * 21) The command is "mysql -h mysql.example.com -u username -p newdbname < olddbexport.sql
 * 22) The mysql.example.com is the Hostname listed on the Goodies -> Manage MySQL page of your panel
 * 23) The username here is the "User with Access" listed for that database (also on the Goodies -> Manage MySQL page) - not your Dreamhost username
 * 24) The newdbname is the name of the Database (also listed on the ManageMySQL page)
 * 25) olddbexport.sql is the name of the export file you saved off the old host that you FTP'd up to the server earlier in these steps
 * 26) The process should appear to hang for a minute or a few depending on the size of your database and then return you to the shell prompt at which point you can disconnect
 * 27) If your old host was Windows-based you've got some more work cut out for you in the world of phpMyAdmin.  Windows is not case-sensitive so it doesn't care if a table is called g2_AccessMap or g2_accessmap - they are the same to the Windows world.  Linux (which Dreamhost uses of course) on the other hand cares very much and would see those as two different tables.
 * 28) Log into the Dreamhost phpMyAdmin page and click into your Gallery database.  If you see duplicates of every table then you have this problem and need to correct it.  There are a number of utilities and scripts out there that may help but it's not very difficult to do it yourself.
 * 29) To play it safe, I rename the current blank tables first to CurrentNameOld so in the earlier example my g2_AccessMap table would be renamed to g2_AccessMapOld.
 * 30) Next I rename the "real" table to the valid mixed-case name so g2_accessmap becomes g2_AccessMap
 * 31) The command is "rename table old_table_name to new_table_name" so for the above example it would be "rename table g2_accessmap to g2_AccessMap"
 * 32) These commands are entered by clicking on the SQL tab at the top.  This takes you to a window where you can type in your SQL commands and then click "Go" to run them.
 * 33) To save time and a ton of typing you can issue multiple SQL commands all in that same window by separating them with a ; character.
 * 34) I used Excel to generate all of the rename commands for me.  NOTE that not all tables will need to be renamed - only ones that were imported and are now duplicated
 * 35) If you expand the spreadsheet lines down and just fill in the table names in Column B then you can just copy and past the contents of Column G into the SQL window and issue them, then do the same with Column J
 * 36) Note Column C has a space before and after the word "to" - this is vital
 * 37) Once your database is all set just run the upgrade sequence
 * 38) Now you need to go into the Site Admin page of your new Gallery and re-load all your plugins you want
 * If you had plugins enabled already such as ImageMagick you will need to click into them and double-check the path to the binaries otherwise they won't run right.
 * You may need to rebuild your thumbnails. This process took me forever and seemed to freeze up often - most likely because of how long the process was taking.  It did eventually work though.

Spreadsheet Columns: Column A = rename table g2_ Column B = ProperCaseTableName Column C = to     Column D = g2_ Column E = B1   Column F = Old; Column G = CONCATENATE(A1,B1,C1,D1,E1,F1) Column H = LOWER(B1) Column I = ; Column J = CONCATENATE(A1,H1,C1,D1,B1,I1)

= External Links =
 * http://gallery.menalto.com/ Gallery homepage
 * Installing ffmpeg for Gallery
 * A specific DreamHost Forums post that contains a fix for the install error "unable to connect to database with the information provided"