Skip to content

Ruby on Rails on OS X with Mongrel and MySQL

Posted on 30 September 2006

Update: Leopard comes with Rails installed. Check out my quick guide.

This is not so much an installation guide, but some general notes regarding how I went about getting Ruby on Rails running on Mac OS X 10.4 (Tiger) from scratch.

For exact installation details I used a few different sources. The hivelogic.com article was the most useful I found, although I wanted to go with Mongrel web server. That meant I didn't need to install LightTPD, FastCGI or PCRE.

Xcode

First I needed Xcode 2.0 or newer. This came on disc 1 of the OS X cd's I got with my macbook.

Path

The hive article then recommended setting up a path. This means MySQL commands can be executed right from the command line. The path is set to look for files in /usr/local using a file called .bash_login. At the end of this file is the following line:

export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"

The file resides in the root of the home folder.

Readline

Readline is a pre-requisite for Ruby on OS X.

In the terminal I navigated to the folder where I unpacked the download to and typed:

./configure --prefix=/usr/local
sudo make
sudo make install

Ruby

I downloaded the latest version of Ruby and navigated in the terminal to the download location and typed the following:

./configure --prefix=/usr/local --enable-pthread --with-readline-dir=/usr/local
sudo make
sudo make install
sudo make install-doc

Rubygems

Again getting the latest version of Rubygems first, I then used the terminal to run the following when in the download location folder:

sudo /usr/local/bin/ruby setup.rb

Ruby on Rails

Now Ruby and Rubygems are installed we can install Rails straight from the terminal

sudo gem install rails --include-dependencies

MySQL

MySQL actually comes as an install package which means no need for the terminal for installation. I downloaded the Mac OS X 10.4 (x86) install package, which is specific for Intel Macs.

It's also recommended to setup MySQL Native Bindings for a performance boost on the MySQL adapter:

sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql

For managing my databases I use CocoaMySQL

Mongrel

Mongrel can installed be installed straight from the terminal:

sudo gem install mongrel

And that is all you need! You start Mongrel by navigating to your app folder in the terminal and using:

mongrel_rails start

View the snippets archive ››

No comments have been left

Got something to say?

About

Paul is a web developer for Kyanmedia web agency. He's lucky enough to write in Ruby on Rails full-time and uses this site to post snippets of code.

Contact

my name at gmail.com

More snippets

Take a look in the archive

Need a website?

Contact my employer. Make sure to check out our portfolio of work.

Hosting

I recommend hostingrails.com