Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blaix/118713 to your computer and use it in GitHub Desktop.
Save blaix/118713 to your computer and use it in GitHub Desktop.
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: http://developer.apple.com/tools/download/
Install macports. This gives you a FreeBSD-like "port" command for installing open-source software that has been ported to OS X. http://www.macports.org/install.php
You'll need to add the macports executables directories to your $PATH environment varilable. There are several ways to do this. If this your first time editing the $PATH, you can update your own user's $PATH by doing this in the Terminal (/Applications/Utilities/Terminal.app):
echo "export $PATH=/opt/local/bin:/opt/local/sbin:$PATH" >> ~/.bash_profile
Now you need to reload .bash_profile:
source ~/.bash_profile
Now you should see the path to the "port" command when you run this:
which port
Time to install ruby! You can do this via macports.
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:
wget -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
LLLLLLets install rails now!
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). Alternatively, you can run it as a daemon in the background like this:
ruby script/server -d
To stop it, you'll have to find the pid and kill it. I'll leave that as an exersize for the reader.
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!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment