Introduction
There a numerous ways of setting up Ruby On Rails server under OSX, but not all of them are simple. For instance there is the definitive way: install Ruby (bundled with OSX, as of 10.4), install RubyGems, install Rails, then install MySQL: a method in which Tiger users will often be thrown an error when installing MySQL. By the time you have found this, I expect you will have encountered this problem, and various fixes aren’t working.
Then there is the Locomotive way. Locomotive is bundled with the LightHTTPd webserver, as well as the SQLite 3 SQL server. It’s great: it’s free, it’s easy to install, and if Rails isn’t for you, then it’s easy to get rid of too.
However, I like many people, already run Apache and MySQL (I’m a PHP developer at heart) and I want to keep my databases in the same place, accessing them through the same account. As much as I respect SQLite, I wanted to stick with what I know. Besides, MySQL seems to have a greater user base, even under Rails.
In this quick tutorial I am going to show you how to setup a Rails development server on a local Mac (OSX 10.4), using Locomotive (LightHTTPd) and MAMP (MySQL), hopefully in under ten minutes.
Who This Is For
I suppose I should start with who this is not for…
This is a quick and (hopefully) painless method, it is not for anyone who uses Rails regularly (although, I expect that a fair few developers use this) and I would advise doing things as David Heinemeier Hansson and co suggest if you really get into the framework.
But, if you know a thing or two about other languages, are comfortable with MySQL, and don’t want any hassle, any commitment, and any command line then I think this might be a good starting point.
I’ll just say, it worked for me.
1. Downloads
I would advise downloading the following applications before you begin, but do them whilst one is installing. Whatever.
MAMP (Current Version: 1.4.1) - MAMP stands for Mac Apache MySQL and PHP and given that you are about to install Rails, I expect that you either run this, or have some idea of the technologies.
Locomotive (Current Version: 2.0.8) - This is our Ruby On Rails server.
CocoaMySQL (Current Version: 0.7b5) - A MySQL front end for OSX. This isn’t essential, but it sure beats configuring your database in the Terminal.
2. Install
Install MAMP as you would usually, run it, it should automatically open it’s own welcome page (Probably http://localhost/MAMP/?language=English) - if this works then we’re up and running. Notice that the username and password to your MySQL account are both “root” - You might want to change these, but you can figure that one out yourself.
Now, this isn’t essential, but it’s something I like to do. Go to the “Preferences” menu of MAMP and hit the “Set to default Apace and MySQL ports” button. This should make them ports 80 and 3306 respectively. It should then restart, but quit it anyway.
Now you have your MySQL server up and running, we must install Locomotive. Once installed go to the bottom-left-hand corner and click the add button. Create a new Rails application with the following:
- Application Name: test
- Application Directory: ~/Sites (This is the path to my Sites directory, but you can use any)
- Framework: Standard Rails [release date]
Now point your browser at http://localhost:3000, where “3000″ is the port number of your Rails application (this can be changed by right clicking “Get Info” in Locomotive.
You should be greeted with the “Welcome aboard” screen! If you get this then the hard part is over, and you are finally “on rails”.
Finally, if you do so wish, install CocoaMySQL, and read on.
3. Setup An Application
Now open up your text editor of choice and open, for example, /Users/Samuel/Sites/test/config/database.yml. “Test” is where my application begins. Now find where it says “development:” and fill this in:
- adapter: mysql
- database: test_development
- username: root
- password: root
- host: localhost
- socket: /Applications/MAMP/tmp/mysql/mysql.sock
Then repeat for the “test” and “production” databases, substituting the username and password for whatever you chose.
This gives you the name for your three databases, although only development is necessary at the moment.
Conclusion
There we go. It may not be the best method, but it’s sure the easiest.
And no command line.








