Most readers can probably skip this, but I’ve recently been asked about setting up a rails development environment and figured it would be nice if I had somewhere to point them with an up-to-date, concise list of steps to get up and running. I believe the following is the easiest, most straightforward way to start with rails on OS X:
Make sure you have XCode installed. This is so you have the necessary compilers and libraries. You can find it on your OS X install DVD, or download it here.
Install macports. This gives you a FreeBSD-like “port” command for installing open-source software that has been ported to OS X.
Time to install ruby! You can do this via macports in the Terminal (/Applications/Utilities/Terminal):
sudo port install ruby
You should go ahead and install wget too. It’s handy. Plus you’ll need it for the next step:
sudo port install wget
The package manager for ruby libraries is rubygems. The macports version is usually outdated, you can install it from source by going to: http://rubyforge.org/projects/rubygems/, clicking “download” for the “rubygems” package, then finding the most recent “.tgz” release, and copying the url. Now, in terminal, run these commands to unpack and install (the rubyforge url I’m using is the most recent at the time I wrote this):
wget http://rubyforge.org/frs/download.php/56227/rubygems-1.3.3.tgz
tar -xzvf rubygems-1.3.3.tgz
cd rubygems-1.3.3
sudo ruby setup.rb
Now this should show you the version number you just installed:
gem -v
Before we start installing gems, go ahead and install mysql:
sudo port install mysql5 +server
It will end by giving you some commands to run to initialize the database and set it up to auto-run on boot. Go ahead and run those commands.
Then install the mysql bindings for ruby:
sudo gem install mysql -- --with-mysql-config=/opt/local/bin/mysql_config5
Lets install rails!
sudo gem install rails
This will install rails and all dependencies. When it’s done you should have a “rails” command in your path. You can use that to initialize your first app:
rails myapp
That will create a shell application with all the necessary files and directories. Hop in there and fire up a development server:
cd myapp
ruby script/server
This will leave the server running in the terminal. To stop the server, type ^c (Ctrl-C).
Now fire up a web browser and visit: http://localhost:3000/ You should see a rails welcome page with some instructions for getting started. Have fun!




