Note: If you're looking for an installation guide for Gallery2 on Mac OS X 10.5 Leopard, see the Gallery2:Installation on Mac OS X 10.5 Leopard page.
Installing Gallery2 on Mac OSX 10.4.9 ("Tiger") is relatively easy, but some knowledge of Mac OS X's Unix under-pinnings is required: this guide won't hold your hand through every detail of every step.
Mac OS X 10.4 already comes with Apache, and PHP. All you need do is install a database, Gallery2, and the graphics library plug-ins. Think you can handle that if I point you to the right places? Then let's go.
Incidentally, this page previously contained the following instructions, which, frankly, are rather brief. You may choose to follow them. Here they are:
Did you decide to stay here? Let's get on with things then.
To get Gallery2 working in Tiger, we need to perform the following steps:
Note: at the time of writing (June 2007), Mac OS X 10.5 ("Leopard") is planned for release in the fall of 2007, and beta versions are available for developers already. If you're reading this and using Mac OS X 10.5 on your Mac, you will need to modify these instructions to suit the new operating system.
This step is fairly obvious. Why Tiger? Because it's known to work, and is well-supported. If you're considering using Leopard, take into account the strong possibility that tools like MySQL, MacPorts, and even Gallery2 may not work out-of-the-box, as they do in Tiger. It can take several months to a year for software packages to be updated so that they run seamlessly on a new operating system version.
To create or view instructions for Mac OS X 10.5 Leopard, see the Gallery2:Installation on Mac OS X 10.5 Leopard page.
Apple's Xcode (formerly Developer Tools) is required by MacPorts to compile and install the graphics package toolkits used by Gallery2. If you purchased your Mac recently, you should have an Xcode installation DVD. Xcode can also be downloaded from Apple's Developer Connection web site.
At the time of writing, Xcode was at version 2.4.1.
xcode_2.4.1_8m1910_6936315.dmg (930 MB)
Unpack and perform a basic install of Xcode. The Xcode install is simple and straightforward, but may take awhile to complete.
The most common database used in Gallery 2 installations is MySQL. MySQL is free, powerful, and widely supported. The PostgreSQL database is also and option and is freely available for Mac OS X.
You can download MySQL appropriate for your system (PPC or Intel) from the MySQL web site. You may also want to download and install the GUI Tools for MySQL, as they provide a nice front-end interface to your database. Install MySQL, as well as the StartupItem package, and MySQL.prefPane. The latter items will allow you to start and stop MySQL from the OS X System Preferences.
IMPORTANT: You should secure your MySQL installation immediately after installation. To do so, start the server from the System Preferences or the command line with the following:
sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &
Then set the MySQL root user's password with
/usr/local/mysql/bin/mysqladmin -u root password MYSQL-ROOT-USER-PASSWORD
If you are new to MySQL, you are strongly encouraged to review MySQL security guidelines.
After you've secured your MySQL installation, you need to create a new database. You can do this from the command line or through the MySQL GUI Tools, if you installed them. Decide on a name for the database, perhaps "gallery2". From the command line, enter the following:
mysqladmin -u root -p create gallery2 Password: MYSQL-ROOT-USER-PASSWORD
If you don't get an error message, a database named gallery2 has been created. Now you need to create and assign a user to connect to the database. This username and password will be used by Gallery 2 to connect to the database. In the following example, the username is "myusername", the password is "mypassword", and the database remains "gallery2" (edit accordingly):
mysql gallery2 -u root -p -e "GRANT ALL ON gallery2.* TO myusername@localhost IDENTIFIED BY 'GALLERY-MYSQL-USER-PASSWORD'"
Note the single quotes around the password, and the double-quotes after the -e parameter.
If you haven't already turned on Apache in Mac OS X, do that now. You can turn it on by going to the System Preferences, choosing the Sharing panel, then adding a tick beside "Personal Web Sharing". This activates the Apache daemon on your Mac.
By default, Mac OS X 10.4's Apache configuration has PHP turned off. You need to enable it in the Apache configuration file, /etc/httpd/httpd.conf. Use a text editor to uncomment line 240, so the line looks like this:
LoadModule php4_module libexec/httpd/libphp4.so
Then uncomment like 284, so the line looks like this:
If you have a slightly different version of Mac OS X or Apache, just look for "php4" to find the two lines above, and uncomment them. Uncommenting these lines enables PHP in Apache.
Once you've saved your changes, then restart Apache with the following command:
sudo /System/Library/StartupItems/Apache/Apache restart
Download and install Gallery2. Installation consists of extracting the files from the Gallery2 archive into a folder in the document root folder on your system. A likely candidate for that folder is:
/Library/WebServer/Documents is the default document root folder for your Mac, and as you can see, the gallery2 folder lies just beneath the root. To access Gallery2, you'd type the following URL into a web browser (assuming that your computer is named MyLovelyMac):
If you're serving Gallery2 to the internet, and not just your local network, you'll need to set up your router, DNS, and/or IP information appropriately.
Go through the Gallery2 installation. Remember to give Gallery2 the username, password, and tablespace information you created in MySQL for step three, above.
If you're installing a fresh Gallery2 system, you're done for this step. If you're migrating your Gallery2 data from a previous installation, such as a Linux server or another Mac, things can get more complex here. You should probably ensure that the version of Gallery2 on your previous server is the same version as the one you're installing. If it's not the same version, Gallery2 will probably offer to upgrade the database for you, if the version of Gallery2 on your previous server is older than the version of Gallery2 on your new Mac installation.
Essentially, you need to dump the Gallery2 database tablespace from your old server, import it into your new Gallery2 tablespace on your server, and then copy over all the files from your g2data directory.
To dump the data from your previous install, log on to your previous system and run the following command (the username is "username"; the tablespace is "old_gallery2"):
mysqldump -uusername -p old_gallery2 > old_gallery2_dump.sql
That command creates a file named old_gallery2_dump.sql that you can copy to your new server. Once on your new server, run a command like this to import the dump into your newly created tablespace:
mysql -uusername -p gallery2 < old_gallery2_dump.sql
Now copy the contents of your g2data folder from your old server to the g2data folder on your new server. You may need to chmod the contents so that the web server can read and write the contents. For example, if your g2data directory was /Library/WebServer/g2data, you could run:
sudo chmod -R 777 /Library/WebServer/g2data
MacPorts is a project that makes it very easy to install Unix tools and libraries on your Mac. It is utterly brilliant, and it makes installing the libraries that Gallery2 requires very easy. Remember, you must have Xcode installed before installing MacPorts.
Note that the MacPorts documentation says that you need to update your .bashrc or .bash_profile file so that your environment has the DISPLAY variable set and two MacPort directories in the PATH variable. You may have to do that manually, as the MacPorts installer did not do that on the G4 machine used when writing the instructions on this Gallery 2 installation guide.
Once you have MacPorts installed and your bash environment set, update MacPorts with the following command:
sudo port -d selfupdate
If all went well, you now have everything you need to install the graphics libraries for Gallery2. If you'd prefer a GUI interface to MacPorts, try Porticus, or run the following from the command line:
sudo port install dcraw sudo port install imagemagick sudo port install ffmpeg sudo port install netpbm sudo port install jhead
Once they're all done, the graphic libraries are located on your Mac in /opt/local/bin. This means that when you enable the graphic plug-ins in the Gallery2 administrator pages, you enter the following values for the plug-ins:
Path to Dcraw binary: /opt/local/bin/dcraw
Path to FFMPEG: /opt/local/bin/ffmpeg
Directory to ImageMagick/GraphicsMagick binaries: /opt/local/bin/
NetPBM directory: /opt/local/bin/ jhead directory: /opt/local/bin/
Save and test all the plug-ins. If things have gone well, they should all work. You can now use Gallery2 to upload photos and movies (use a tool like iPhotoToGallery):
Your Gallery2 installation works fine now, but you'll notice that you can't upload full resolution files from your nice six megapixel camera. That's because Mac OS X uses the default settings for PHP, and PHP's default settings limit the amount of memory consumed by a PHP program to eight megabytes, and the maximum size for an upload to be two megabytes.
To change these settings, you'll need to copy /etc/php.ini.default to /etc/php.ini and change the following default values (you'll need to use the sudo command again, because these are system files):
Line 232 (up the memory limit from eight megabytes to something more like sixteen):
memory_limit = 8M
Line 373 (up the maximum post file size to something more like sixteen megabytes):
post_max_size = 8M
Line 489 (up the maximum uploadable file size from two to something like sixteen):
upload_max_filesize = 2M
Now that you've made the change, restart Apache and you will be able to upload larger file sizes. Awesome!
sudo /System/Library/StartupItems/Apache/Apache restart
If all went well, you should now have the world's best photo sharing tool running on the best operating system in the world and the best hardware.
The author of this page hopes that this guide has been of some use to you. As time goes on, this information will become more and more obsolete and things won't work as well as they did when the guide was written. Please feel free to add your own changes where you feel they are necessary.
When Mac OS X 10.5 (Leopard) is released, the Gallery2:Installation on Mac OS X 10.5 Leopard page can be completed. That way, the known-to-be-working instructions for Mac OS X 10.4 Tiger are preserved here, while the brave souls who venture forth into the unknown territory of Leopard can forge ahead while the more conservative Gallery2 users can stick with what is known to work.