Ruby, PHP, MySQL, and Perl issues when upgrading Mac OS X from Leopard to Snow Leopard

I bought Mac OS X 10.6 (Snow Leopard) on the day it was released, but didn't gather enough courage to go ahead and install it until a week ago. Yep, it's been collecting dust on my shelf for over six months.

Upgrading between major revisions of Mac OS X has bitten me several times in the past, mostly because I use my Mac as a web development machine. I need Apache, PHP, MySQL, Perl, Ruby and a whole bunch of Ruby gems in working order, and it seems like major OS X updates almost always mess with those in one way or another.

As I expected I ran into some trouble, though it wasn't as bad as I had feared. I had done a bit of research before I took the plunge so I knew pretty much what was going to break. It still took me a few hours of anxious nail biting before I finally had everything back to normal and could relax.

Just in case I need to repeat this procedure some time, and in case there are others who run into some of the problems I did while upgrading Mac OS X from Leopard to Snow Leopard, here's the story.


Never, ever, do a full version upgrade without at least one reliable backup of the disk you are installing to. I use Time Machine for continuous backups, but to be extra safe I used Carbon Copy Cloner to make a bootable clone on a separate disk. That turned out to be a very good thing.

With the backups checked and verified, I turned off Time Machine in the control panel and unplugged both of the external drives. I did not want to accidentally install Snow Leopard over one of the backups.

Install, take one

Ok, time to install. I plopped in the Snow Leopard disc and let it reboot. Since my system has been with me for several major Mac OS X revisions and thereby accumulated old versions of this and that, I wanted to do a clean install this time. So I used the Disk Utility provided by the Snow Leopard installer and wiped my disk, then installed 10.6. No apparent problems so far.

Import data and applications, take one

When the installation was done, I plugged my Time Machine disk back in and let the Migration Assistant import my user account, applications, settings, and other files. After that, time to login. And time to find the first problem: my Dock was full of question marks. My third party applications had not been transfered. The somewhat embarrassing explanation for that? Well, since I had added an exception for the Applications folder to Time Machine there were no applications on my backup disk for Migration Assistant to transfer... D'oh!

However, there were other things that didn't seem right. My displays were arranged differently, the default desktop background was there, iTunes said it was too old for my music library, etc. So I decided to start over instead of troubleshooting.

Install, take two

Like the first time, I unplugged my external drives to make sure I didn't accidentally erase or overwrite them. I repeated the erase and install procedure.

Import data and applications, take two

This is where that bootable clone I made came in handy. After installing I plugged in the clone disk and told the Migration Assistant to import “From another Mac” and then selected the clone. A long time of intensive hard drive activity later it was done and I could log into my account.

This time my applications were there and all my settings seemed to have been transfered. Phew.

Software update

After unplugging the clone disk again I installed Xcode since I knew I was going to need the developer tools later on. Next I ran Software Update to make sure everything was up to date.


For one project I'm working on I use Ruby. Ruby itself was not a problem, but a couple of the gems were: Nokogiri and Phusion Passenger. Fixing Nokogiri is done by simply reinstalling it (sudo gem install nokogiri). Phusion Passenger takes just a little more effort:

  1. Reinstall Passenger (sudo gem install -r passenger)
  2. Reinstall Passenger’s Apache module (sudo passenger-install-apache2-module)
  3. Update /etc/apache2/httpd.conf according to the message the installer shows
  4. Restart Apache

Passenger actually caused an error it took me a while to figure out. When I first tried to load one of my dev sites (one that does not use Ruby), my browser told me that it couldn't open the page “because the server unexpectedly dropped the connection”. At first I thought this was related to something else, but it was reinstalling Passenger that did the trick.


I use PHP's date() function, and this produced a warning message about no timezone being specified. The fix for this is to set a timezone in /etc/php.ini. But that file didn’t exist, so I had to create one by making a copy of /etc/php.ini.default and editing that:

  1. sudo cp /etc/php.ini.default /etc/php.ini
  2. On line 997 or thereabouts, change ;date.timezone = to date.timezone = Europe/Stockholm. Not in Sweden? See the List of Supported Timezones.


Seems like MySQL is not included with Snow Leopard. At least I couldn't find it anywhere. So before fixing it up I had to install it.

  1. Download and install mysql-5.1.45-osx10.6-x86_64.dmg from the Download MySQL Community Server page.
  2. PHP won't know how to connect to MySQL until you either open /etc/php.ini and replace all occurences of /var/mysql/mysql.sock with /tmp/mysql.sock, or create a symlink: sudo ln -s /var/mysql/mysql.sock /tmp/mysql.sock.
  3. Set a password for the root mysql user: mysqladmin -u root password newpass.
  4. I couldn't figure out how to copy the MySQL database files from my backup disk, so I used phpMyAdmin to import database dumps, create users and assign privileges. To be able to import my databases through phpmyadmin, I had to open /etc/php.ini and change upload_max_filesize = 2M to upload_max_filesize = 10M.

Perl DBI

Almost everything was working now, but I couldn't log in to my local install of Movable Type. This time it was Perl that could not connect to MySQL. To fix that I had to install Perl DBI: sudo cpan DBD::mysql.

Turn Time Machine back on

Finally, after verifying that everything was working as I expected, it was time to plug the Time Machine disk back in and start Time Machine.

I was pretty sure that since I did an erase and install I would have to start from scratch with Time Machine. Much to my surprise I did not – Time Machine recognised my disk and went ahead to backup the changed files, keeping my backup history intact. Yay!

Executive summary

  1. Make at least one bootable backup
  2. Erase and install
  3. Migrate data from clone
  4. Install Xcode
  5. Run Software Update
  6. Reinstall Ruby gems
  7. Create php.ini
  8. Install and configure MySQL
  9. Install Perl DBI
  10. Turn Time Machine back on


Obviously I would never have figured all of this out on my own. Thanks to the authors of the following articles:

Posted on March 26, 2010 in Mac, PHP, Movable Type