Company > Overview > White Papers & Articles > Install Ruby and Rails on Mac OS X
With more than 20 years of combined experience in web development, data warehousing, and business analysis, ADS knows how to take your business to the next level.
Install Ruby and Rails on Mac OS X
Installing everything you need to begin Ruby on Rails development on your Mac is a lot easier than one might think. We will take your step-by-step through the process of installing Ruby, Rails, MySQL, and all the necessities so you can start developing right away. Let’s get ready to begin!
Step 0: Install iTerm (optional)
We like terminal but we like iTerm even better. iTerm has tabs which makes it super easy to multitask.
- Download the latest version of iTerm
- Double-click on .dmg file
- Install iTerm as you would any Mac application.
Step 1: Install Xcode Tools
The Xcode tools are an absolute necessity.
- Download the latest version of Xcode from the Apple Developer Connection
- Double-click on xcode_2.4.1.dmg
- Install Xcode as you would any Mac application.
Step 2: Install MacPorts
MacPorts is the newest version of Darwin Ports. MacPorts is a great package manager for Mac, and we will use this to install most of what we need.
1. As usual, download the latest version of MacPorts 2. Double-click on MacPorts-1.6.0-10.3-Panther.dmg 3. Install MacPorts as you would any Mac application.
Once installed, let’s test it. Pop open iTerm and run the following:
$ port version $ version 1.600
Step 3: Install the Ruby on Rails Development Stack
Now we will install Ruby and Rails. There will be a few steps that can take a bit depending on the Internet connection you have. Let’s begin!
Step 3.1: Install Ruby and RubyGems
$ sudo port install ruby rb-rubygems
Once that is complete, let’s run the following to ensure it is working properly:
$ ruby -v $ ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-darwin8.9.1]
Looks good. Now to check that Ruby is working as expected:
$ irb irb(main):001:0> x = 1 => 1 irb(main):002:0> puts "Rails For All is great" if x == 1 Rails For All is great
Step 3.2: Install Ruby on Rails (2.1)
The moment we have all been waiting for, Ruby on Rails. Essentially, Ruby on Rails is a gem so we install it as such:
When the above command is run, you will see something similar to this: <pre> Successfully installed rake-0.8.1 Successfully installed activesupport-2.1.0 Successfully installed activerecord-2.1.0 Successfully installed actionpack-2.1.0 Successfully installed actionmailer-2.1.0 Successfully installed rails-2.1.0 6 gems installed Installing ri documentation for rake-0.8.1... Installing ri documentation for activesupport-2.1.0... Installing ri documentation for activerecord-2.1.0... Installing ri documentation for actionpack-2.1.0... Installing ri documentation for actionmailer-2.1.0... Installing RDoc documentation for rake-0.8.1... Installing RDoc documentation for activesupport-2.1.0... Installing RDoc documentation for activerecord-2.1.0... Installing RDoc documentation for actionpack-2.1.0... Installing RDoc documentation for actionmailer-2.1.0... </pre> *Step 3.3: Let's get rich and add more gems* The 'standard' application server used for most Rails deployments is Mongrel. Let's get it going on our dev machine so we can learn more about it. <pre> $ sudo gem install mongrel mongrel_cluster </pre> When you are prompted to choose the gem(s) for your platform, select the latest version that has (ruby) beside the name. Next, we need a database. *Step 3.4: Install MySQL* A lot of Rails applications are run on MySQL, and for local development purposes we will install it. To get things going, we are going to keep it simple and install MySQL from .dmg packages. # Grab the latest and greatest version of MySQL (package format) "from the MySQL website":http://dev.mysql.com/downloads/mysql/5.0.html#macosx-dmg # Double-click on the .dmg MySQL package that to mount the image # Locate the MySQL installer (a file named something like mysql-5.0.51b-osx10.5-i686.pkg) and run it, authenticating as needed # Double-click MySQLStartupItem.pkg, authenticate, and let it install # Double-click MySQL.prefPane and install it, deciding whether to make it available to just the current user, or for all system users Once the install is complete, start the MySQL server using the newly-installed control panel. *Note:* MySQL installs with a default user of root using no password. If you care about the privacy of your data or computer, please read this page about MySQL usernames and passwords and set a good one. Next, we will install the MySQL gem. While not necessary, the performance gains seem to be worth it. <pre> $ sudo gem install mysql --with-mysql-dir=/usr/local/mysql </pre> As with the other installs, you will be prompted to choose your version. Select the latest version with (ruby) beside it. Once that is complete, there is one more step - installing Capistrano. Capistrano is a gem that makes deployment of your Rails apps easy. As with all of the other gems, choose the latest version with (ruby) beside it. <pre> $ sudo gem install capistrano </pre> That's it! We are now ready to start developing Ruby on Rails applications. *Step 4: Additional Tools* One additional tool that will make your life easier is "CocoaMySQL":http://cocoamysql.sourceforge.net, a free GUI tool to work with MySQL. You can install is just like any other Mac application.
