--- title: OSX inMenu: true directoryName: OSX --- h1. OS X + Ruby on Rails + Mongrel + MySQL in 15 minutes

*by "Elliott Hird":http://elliotthird.org/*

Most tutorials about this seem to involve either manually compiling everything or they take some totally unneccesary long-winded detour. But it's really easy.

Anyway, let's get started.

h2. Installing MacPorts?

_(If you already have MacPorts? installed, you can skip this step.)_

You'll be able to follow "this tutorial":http://trac.macosforge.org/projects/macports/wiki/InstallingMacPorts for the most part, but skip installing X11.

_Disclaimer: The time spent installing MacPorts? does not add up to the time spent following this tutorial. Yes, I cheated._

h2. Installing Ruby

Well, technically, you already have ruby. Look: <pre> $ ruby -v ruby 1.8.2 [stuff follows] </pre>

_(The version number may be different for you.)_

But depending on what OS X version you're on, it's either broken or outdated. Let's get a working copy of 1.8.5. Fire up your "terminal of choice":http://iterm.sourceforge.net/ and install ruby: <pre> $ sudo port install ruby [lots of text showing macports compiling things] </pre> That was easy, wasn't it?

h2. Installing RubyGems? (these titles have very little variation)

Grab the latest RubyGems? version from "here":http://rubyforge.org/frs/?group_id=126 (grab either the .tgz or .zip version, either is fine but the .tgz is smaller) and extract it to wherever you want (in Tiger, just double click on it).

Open your terminal of choice and install it: <pre> $ cd ~/Desktop/rubygems-0.9.0 $ sudo ruby install.rb [things] </pre> Hopefully that worked. If it didn't, well then, I can't help you. Ask somebody else.

h2. Did that work?

Now simply type: <pre> $ gem [boring usage instructions] </pre> Yay! RubyGems? works (again, if it doesn't, I have no idea what's wrong).

h2. Installing Rails

Now: <pre> $ sudo gem install rails --include-dependencies </pre> After a few minutes, it should dump you back to the prompt without errors. Make sure it works: <pre> $ rails </pre> If you want to update rails to the latest (at the time of writing) release candidate of 1.2, see the last section. For now, just wait.

h2. MySQL!

You might think MySQL, being a big bloated thing, would take all day to compile. Not so - it only took about 2 minutes for me. Your mileage may vary. <pre> $ sudo port install mysql +server </pre> Note the server variant is selected by using +server. This is required, so just leave it, mmkay?

After compiling and installing all that, it should give you a notice about how to start MySQL at startup. I highly reccomend doing this, it doesn't make startup any slower.

If you've told MySQL to start at bootup, reboot now. I'll wait for you.

h2. Add some Mongrel to the mix

This one is simple. <pre> $ sudo gem install mongrel --include-dependencies </pre> Choose the first one and wait for it to install.

h2. Testing it out

Alright then. <pre> $ cd ~/Code $ rails test $ cd test $ mongrel_rails start </pre> If all goes well Mongrel should start up. To test it, "load this":http://localhost:3000. If you see the Rails welcome screen - you're done!

h2. That's All, Folks!

No, really.

Actually, that was a bit more than 15 minutes, wasn't it? Oh well.

h2. Additional things

These aren't neccesary, but some people like to do them.

h3. Updating Rails to 1.2rc1

This one is easy. <pre> $ gem update rails --source http://gems.rubyonrails.org/ --include-depdendencies </pre>

h3. Securing MySQL

By default, nobody except localhost can access MySQL, but it allows any user to login (although they can't do anything) and root has no password. I don't see this as a problem since nobody that isn't at your computer can take advantage of this and it's development anyway, but if you want to secure it you're on your own.