how to install ruby on rails on MacOS X Mavericks ( 10.9 ) with mysql step by step

In this tutorial i will guide you through the steps for installing ruby and rails gem on your freshly installed MacOS X mavericks 10.9 . in this tutorial i will use RVM ( ruby version manager ) to install ruby and nano as a text editor . so let’s get started

Install required Components

1 . xcode (command line tools )

Install xcode and then install command line tools or just install command line tools stand alone  . open terminal and type

xcode-select --install

and choose install
2 . Homebrew

homebrew is awesome package manager for mac , if you used mac before its most chances that you know about that and for the newbie  its like apt-get and yum-install tool for mac

open terminal and paste :

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"

after installation open terminal and run

 brew doctor

Start Installation

1 . Installing mysql ( & setup path )]

i prefer mysql as my database . there are two most common ways to install mysql in your mac ,  First by using official DMG file Second by using homebrew .

Download mysql

install using homebrew

brew install mysql

after installation open your .bashrc file or if you are using zsh then open .zshrc file

and  add at the end ( for DMG installation )

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

for brew installation

export PATH=$PATH:$(brew --prefix mysql)/bin

2 . Installing  RVM

before installing rvm optionally you can install gcc49

brew tap homebrew/versions
brew install gcc49
brew install autoconf automake libtool libyaml readline libksba openssl

after installation open your .bashrc file and add

#export CC=/usr/local/bin/gcc-4.9
#export CPP=/usr/local/bin/cpp-4.9
#export CXX=/usr/local/bin/g++-4.9

they are COMMENTED out ,  UNCOMMENT that when you facing problem in installing gems ( like libv8 and therubyracer )

my .zshrc my zshrc

now its time to install rvm

\curl -L https://get.rvm.io | bash -s stable

after installation quite terminal and open again and type

type rvm | head -n 1

if installation was successful then you will get

rvm is a function

rvm success

otherwise try to troubleshoot your rvm installation  . ( as your question in our forum )

3 . Installing Ruby

after installing rvm now lets install ruby

rvm install ruby-2.0.0-p247

after installation restart your terminal and type

rvm use 2.0.0-p247 
ruby -v

you will get

ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin13.0.0]

it means now ruby is installed its time to install gems

4 . Installing Rails ( and other gems )

rails is a gem and installing gem is so easy just type

gem install rails 
gem install mysql2

it will install all dependent gems as well

5 . Verifying installation

after installing gem type

rails -v
Tagged With : - - -
Show Comments( 20 )