<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Robby on Rails: Installing Ruby on Rails, Passenger, PostgreSQL, MySQL, Oh My Zsh on Snow Leopard, Fourth Edition</title>
    <link>http://www.robbyonrails.com/articles/2010/02/08/installing-ruby-on-rails-passenger-postgresql-mysql-oh-my-zsh-on-snow-leopard-fourth-edition</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>thoughts.sort_by{|t| t[:topic]}.collect </description>
    <item>
      <title>Installing Ruby on Rails, Passenger, PostgreSQL, MySQL, Oh My Zsh on Snow Leopard, Fourth Edition</title>
      <description>&lt;p&gt;Welcome to what seems like my tenth installment (actually, it&amp;#8217;s the fourth) of showing you how I setup my development environment on a fresh &lt;span class="caps"&gt;OSX&lt;/span&gt; install. In this case, I&amp;#8217;m actually getting a MacBook setup for a new employee with Snow Leopard.&lt;/p&gt;


	&lt;p&gt;Over the years, I&amp;#8217;ve evolved these following steps and they&amp;#8217;ve helped our team maintain a consistent and stable envirnment for Ruby on Rails development. I know that there are a few other ways to approaching this and I&amp;#8217;m sure you&amp;#8217;ll get similar results, but this approach has allowed me to maintain a hassle-free setup for the last five years.&lt;/p&gt;


	&lt;p&gt;As with all things&amp;#8230; your milage may vary.&lt;/p&gt;


	&lt;h2&gt;Phase One&lt;/h2&gt;


	&lt;p&gt;During this initial phase, we&amp;#8217;re going to install the primary dependencies and setup our environment.&lt;/p&gt;


	&lt;h3&gt;XCode&lt;/h3&gt;


	&lt;p&gt;The first thing that you&amp;#8217;ll need to do is install XCode, which almost everything depends upon as this will install developer-friendly tools for you. Apple has been kind enough to ship this on your Snow Leopard &lt;span class="caps"&gt;DVD&lt;/span&gt;.&lt;/p&gt;


	&lt;p&gt;&lt;img src="http://img.skitch.com/20100208-kmamssde4apw1qxcs6u991p518.jpg" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;Go ahead and install XCode from the &lt;strong&gt;Optional Installs&lt;/strong&gt; folder.&lt;/p&gt;


	&lt;p&gt;&lt;img src="http://img.skitch.com/20100208-1up5s7ahybmryrerrxxwn1d7tu.jpg" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;(might require a reboot)&lt;/p&gt;


	&lt;p&gt;You can also &lt;a href="http://developer.apple.com/technology/xcode.html"&gt;download it&lt;/a&gt; online.&lt;/p&gt;


	&lt;h3&gt;MacPorts&lt;/h3&gt;


	&lt;p&gt;Now we’ll install MacPorts, which the web site describes itself as, &amp;#8220;an open-source community initiative to design an easy-to-use system for compiling, installing, and upgrading either command-line, &lt;span class="caps"&gt;X11&lt;/span&gt; or Aqua based open-source software on the Mac &lt;span class="caps"&gt;OS X&lt;/span&gt; operating system.&amp;#8221;&lt;/p&gt;


	&lt;p&gt;As I&amp;#8217;ve said in past versions of this guide, this tool is about to become one of the most important tools on your operating system. It&amp;#8217;ll be used time and time again to maintain your libraries and many of the Unix tools that you&amp;#8217;ll be using. If you&amp;#8217;re from the Linux or &lt;span class="caps"&gt;BSD&lt;/span&gt; world, you are likely familiar with similar tools… such as: &lt;code&gt;apt-get&lt;/code&gt;, &lt;code&gt;port&lt;/code&gt;, and &lt;code&gt;yum&lt;/code&gt;.&lt;/p&gt;


	&lt;p&gt;You&amp;#8217;ll want to download the latest stable version from &lt;a href="http://www.macports.org"&gt;http://www.macports.org/&lt;/a&gt;. Once downloaded, you can install it.&lt;/p&gt;


	&lt;p&gt;&lt;img src="http://img.skitch.com/20100208-fd4h7rd16437yd63hf45mkn592.jpg" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;Once this is installed, you&amp;#8217;ll be able to use the &lt;code&gt;port&lt;/code&gt; command from your console.&lt;/p&gt;


	&lt;h3&gt;Wget&lt;/h3&gt;


	&lt;p&gt;Let&amp;#8217;s test out your MacPorts install by installing a useful tool called wget, which we&amp;#8217;ll use to install oh-my-zsh.&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;sudo port install wget&lt;/code&gt;&lt;/p&gt;


	&lt;h3&gt;Git and Subversion&lt;/h3&gt;


	&lt;p&gt;Every development environment should have some source code management tools available. We&amp;#8217;ll install both of these with one command.&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;sudo port install git-core +svn&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;This will install git and subversion.&lt;/p&gt;


	&lt;h3&gt;oh-my-zsh&lt;/h3&gt;


	&lt;p&gt;&lt;a href="http://github.com/robbyrussell/oh-my-zsh"&gt;Oh My Zsh&lt;/a&gt; is the most amazing thing to happen to shells since&amp;#8230; well since I said so. It&amp;#8217;s one of my open source projects that I encourage you to give a whirl.&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;wget http://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;That&amp;#8217;s it. The next time you open up your terminal, you&amp;#8217;ll be running zsh with a bunch of stuff available. For more information, visit &lt;a href="http://github.com/robbyrussell/oh-my-zsh"&gt;http://github.com/robbyrussell/oh-my-zsh&lt;/a&gt;.&lt;/p&gt;


	&lt;h3&gt;Terminal theme (optional)&lt;/h3&gt;


	&lt;p&gt;I never understood why the icon for Terminal has a black background but when you start it up the default theme is black on white.&lt;/p&gt;


	&lt;p&gt;&lt;img src="http://img.skitch.com/20100208-1b92cbx8gtuttqsbdd49qspq7f.jpg" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;versus&lt;/p&gt;


	&lt;p&gt;&lt;img src="http://img.skitch.com/20100208-8dnmpswyumfk73h942g6u4fih4.jpg" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;Anyhow, I&amp;#8217;m a fan of the the dark background. To change this, open up preferences in Terminal. Select &lt;strong&gt;Pro&lt;/strong&gt;, then click on the &lt;strong&gt;Default&lt;/strong&gt; window so that this sticks around.&lt;/p&gt;


	&lt;p&gt;&lt;img src="http://img.skitch.com/20100208-mr4q4y5btq7sscuh7ceky3ahgx.jpg" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;Let&amp;#8217;s now open up a new Terminal window..&lt;/p&gt;


	&lt;p&gt;You should be looking at something like this:&lt;/p&gt;


	&lt;p&gt;&lt;img src="http://img.skitch.com/20100208-psmj7mqsx38j1i2nj75n6hbcg7.jpg" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;Much better&amp;#8230; let&amp;#8217;s continue.&lt;/p&gt;


	&lt;h2&gt;Phase Two&lt;/h2&gt;


	&lt;p&gt;We&amp;#8217;re now going to start installing everything we need to get this running.&lt;/p&gt;


	&lt;h3&gt;Ruby 1.8.7.x&lt;/h3&gt;


	&lt;p&gt;First up, Ruby.&lt;/p&gt;


	&lt;p&gt;Snow Leopard includes Ruby and Rails already installed, but we&amp;#8217;re going to back these up for a rainy day. Just issue these  commands:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
$ sudo su -
Password:
:~ root# mv /usr/bin/ruby /usr/bin/ruby.orig
:~ root# mv /usr/bin/gem /usr/bin/gem.orig
:~ root# mv /usr/bin/rails /usr/bin/rails.orig
:~ root# logout
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;&lt;img src="http://img.skitch.com/20100208-b7cxbt8andg3t7ntn17r1wahfg.jpg" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;Now we&amp;#8217;ll go ahead and install a fresh copy of Ruby and RubyGems via MacPorts.&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;sudo port install ruby rb-rubygems&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;You should now see something like this for a bit&amp;#8230;&lt;/p&gt;


	&lt;p&gt;&lt;img src="http://img.skitch.com/20100208-n9xxiaqbe6bw72qr88dgurxqdp.jpg" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;Let&amp;#8217;s watch a video about bumble bees.&lt;/p&gt;


&lt;object width="560" height="340"&gt;&lt;param name="movie" value="http://www.youtube.com/v/R-o6e57AEGo&amp;#38;hl=en_US&amp;#38;fs=1&amp;#38;color1=0x5d1719&amp;#38;color2=0xcd311b"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/R-o6e57AEGo&amp;#38;hl=en_US&amp;#38;fs=1&amp;#38;color1=0x5d1719&amp;#38;color2=0xcd311b" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"&gt;&lt;/embed&gt;&lt;/object&gt;

	&lt;p&gt;When it finishes installing, you should check that Ruby is available to you and installed in &lt;code&gt;/opt/local/bin&lt;/code&gt;.&lt;/p&gt;


	&lt;p&gt;&lt;img src="http://img.skitch.com/20100208-tfc3ifeaau15295r9sfmfhbnm1.jpg" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;We&amp;#8217;ll also take a second to create a symlink for this as some tools seem to rely on &lt;code&gt;/usr/bin/ruby&lt;/code&gt; being there.&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;sudo ln -s /opt/local/bin/ruby /usr/bin/ruby&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;Great, let&amp;#8217;s move on.&lt;/p&gt;


	&lt;h3&gt;Passenger (mod_rails)&lt;/h3&gt;


	&lt;p&gt;Now that we have Ruby installed, we&amp;#8217;re going to take a quick detour to setup Passenger with the Apache server already available on your machine. I&amp;#8217;ve been a big fan of using Passenger for your development for over a year now.&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;sudo gem install passenger&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;Once the gem is finished installing, you&amp;#8217;ll need to install the apache2 module with the following command:&lt;/p&gt;


	&lt;p&gt;It&amp;#8217;ll ask you to continue by pressing Enter. At this point, it&amp;#8217;ll check that you have all the necessary dependencies and then compile everything needed for Apache2.&lt;/p&gt;


	&lt;p&gt;&lt;img src="http://img.skitch.com/20100208-x4rcmr6m5q44etk7rad2kqpmir.jpg" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;Now I&amp;#8217;ll force you to watch a highlights reel of Fernando Torres&amp;#8230; &lt;em&gt;the best striker in the world!&lt;/em&gt;&lt;/p&gt;


&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/jRtq6TtSxbE&amp;#38;hl=en_US&amp;#38;fs=1&amp;#38;color1=0x5d1719&amp;#38;color2=0xcd311b"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/jRtq6TtSxbE&amp;#38;hl=en_US&amp;#38;fs=1&amp;#38;color1=0x5d1719&amp;#38;color2=0xcd311b" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;

	&lt;p&gt;The passenger install will then show you this output, which you&amp;#8217;ll want to stop and read for a moment and highlight the following:&lt;/p&gt;


	&lt;p&gt;&lt;img src="http://img.skitch.com/20100208-ms13ub2srx2axk6ti43ifiyut4.jpg" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;Then using vi or emacs, you&amp;#8217;ll want to create a new file with the following content:&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;vi /etc/apache2/other/passenger.conf&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;Then paste in the following (what you highlighted and copied above.)&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
LoadModule passenger_module /opt/local/lib/ruby/gems/1.8/gems/passenger-2.2.9/ext/apache2/mod_passenger.so
PassengerRoot /opt/local/lib/ruby/gems/1.8/gems/passenger-2.2.9
PassengerRuby /opt/local/bin/ruby
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;You&amp;#8217;ll also want to include the following below what you just pasted.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
  # Set the default environment to development
  RailsEnv development

  # Which directory do you want Apache to be able to look into for projects?
  &amp;lt;Directory "/Users/ryangensel/development"&amp;gt;
      Order allow,deny
      Allow from all
  &amp;lt;/Directory&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;You&amp;#8217;ll want to quickly start up your web sharing, which will start Apache2 up via your System Preferences.&lt;/p&gt;


	&lt;p&gt;&lt;img src="http://img.skitch.com/20100208-ekr2g6f5seb6iif35fteyjfi74.jpg" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;&lt;img src="http://img.skitch.com/20100208-rm96gmde4d8ffwjbdyqusiqr8f.jpg" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;Simple enough&amp;#8230; moving forward.&lt;/p&gt;


	&lt;h3&gt;Passenger Pref Pane&lt;/h3&gt;


	&lt;p&gt;To make things as simple as possible, I&amp;#8217;d encourage you to install the &lt;a href="http://www.fngtps.com/2009/09/new-os-more-pane-passenger-preference-pane-v1-3"&gt;Passenger Preference Pane&lt;/a&gt; (view this post for a download).&lt;/p&gt;


	&lt;p&gt;&lt;img src="http://img.skitch.com/20100208-ra8p88abxtnxbq3m9711gbpryb.jpg" alt="" /&gt;&lt;/p&gt;


	&lt;h3&gt;Development directory&lt;/h3&gt;


	&lt;p&gt;I have a directory named &lt;code&gt;development/&lt;/code&gt; in my home directory, which is where I end up storing all of my projects. This should match whatever you put above in the apache configuration (&lt;code&gt;&amp;lt;Directory "/Users/ryangensel/development"&amp;gt;&lt;/code&gt;).&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;mkdir development; cd development;&lt;/code&gt;&lt;/p&gt;


	&lt;h3&gt;Installing Ruby on Rails via RubyGems&lt;/h3&gt;


	&lt;p&gt;Now we&amp;#8217;ll use RubyGems to install the latest version of Ruby on Rails (and all of it&amp;#8217;s dependencies).&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;sudo gem install rails&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;&lt;img src="http://img.skitch.com/20100208-eyhg4t9sscbeiccs5rxkb5p35.jpg" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;While this is installing, you can watch a video from my old band that ended around the time that business started picking up for &lt;a href="http://planetargon.com"&gt;Planet Argon&lt;/a&gt;.&lt;/p&gt;


&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/SJvncb3bVdg&amp;#38;hl=en_US&amp;#38;fs=1&amp;#38;color1=0x5d1719&amp;#38;color2=0xcd311b"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/SJvncb3bVdg&amp;#38;hl=en_US&amp;#38;fs=1&amp;#38;color1=0x5d1719&amp;#38;color2=0xcd311b" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;

	&lt;p&gt;Great, let&amp;#8217;s test out the install of Rails&amp;#8230;&lt;/p&gt;


	&lt;h3&gt;Test Rails and Passenger&lt;/h3&gt;


	&lt;p&gt;In your development directory, let&amp;#8217;s quickly a new Rails app&amp;#8230;&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;rails testapp&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;This will generate a new Rails application in a &lt;code&gt;testapp/&lt;/code&gt; directory.&lt;/p&gt;


	&lt;p&gt;Now open up the &lt;strong&gt;Passenger Preferences Pane&lt;/strong&gt; and add this directory as a new application.&lt;/p&gt;


	&lt;p&gt;&lt;img src="http://img.skitch.com/20100208-83rjan794eqcmy62e1u4aujtiy.jpg" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;&lt;img src="http://img.skitch.com/20100208-tms89ssutthhq8rkpjm392qfpb.jpg" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;Press Apply&amp;#8230;&lt;/p&gt;


	&lt;p&gt;You should now fire up your browser of choice and head to &lt;code&gt;http://testapp.local&lt;/code&gt;. If all has worked, you&amp;#8217;ll see a, &amp;#8220;Welcome aboard&amp;#8221; screen from the Ruby on Rails application.&lt;/p&gt;


	&lt;p&gt;&lt;img src="http://img.skitch.com/20100208-c9phjdfq8ybcu29uc5k9qiuha9.jpg" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;Assuming that this worked for you, let&amp;#8217;s take a quick break to make some tea&amp;#8230;&lt;/p&gt;


	&lt;h2&gt;Phase Three&lt;/h2&gt;


	&lt;p&gt;In this last phase, we&amp;#8217;re going to install a few database servers and corresponding rubygems so that you can get to work.&lt;/p&gt;


	&lt;h3&gt;PostgreSQL&lt;/h3&gt;


	&lt;p&gt;At &lt;a href="http://planetargon.com"&gt;Planet Argon&lt;/a&gt;, we build our web applications on top of &lt;a href="http://postgresql.org"&gt;PostgreSQL&lt;/a&gt;. I&amp;#8217;ve been a long-time advocate of it and hope you consider using it yourself.&lt;/p&gt;


	&lt;p&gt;At this point in time, the current stable version of PostgreSQL via MacPorts is 8.4.x. Let&amp;#8217;s install that now&amp;#8230;&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;sudo port install postgresql84 postgresql84-server&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;Once this finishes compiling, you&amp;#8217;ll need to run the following commands to setup a new PostgreSQL database.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
sudo mkdir -p /opt/local/var/db/postgresql84/defaultdb
sudo chown postgres:postgres /opt/local/var/db/postgresql84/defaultdb
sudo su postgres -c '/opt/local/lib/postgresql84/bin/initdb -D /opt/local/var/db/postgresql84/defaultdb'
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Assuming that you want PostgreSQL to always be running, you can run:&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql84-server.plist&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;...and to start it right now, run:&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;sudo launchctl start org.macports.postgresql84-server&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;Before you can start using it, we&amp;#8217;ll need to make sure that the PostgreSQL executables are available in your shell path. Since you&amp;#8217;re now using &lt;a href="http://github.com/robbyrussell/oh-my-zsh"&gt;oh-my-zsh&lt;/a&gt;, you&amp;#8217;ll want to edit &lt;code&gt;~/.zshrc&lt;/code&gt; with your favorite editor.&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;vi ~/.zshrc&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;Just append this to &lt;code&gt;export PATH=&lt;/code&gt; line in the file.&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;:/opt/local/lib/postgresql84/bin&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;Your &lt;span class="caps"&gt;PATH&lt;/span&gt; might look something like the following now:&lt;/p&gt;


	&lt;p&gt;@# Customize to your needs&amp;#8230;
export &lt;span class="caps"&gt;PATH&lt;/span&gt;=/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/local/lib/postgresql84/bin@&lt;/p&gt;


	&lt;h4&gt;Setup database user&lt;/h4&gt;


	&lt;p&gt;To setup a new database (with superuser credentials), just run:&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;createuser --superuser ryangensel -U postgres&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;We&amp;#8217;ll now test creating a database:&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;createdb test_db&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;Let&amp;#8217;s test that we can access it&amp;#8230;&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
➜  ~  psql test_db
psql (8.4.2)
Type "help" for help.

test_db=# \q
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Great, let&amp;#8217;s drop it now.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
➜  ~  dropdb test_db
➜  ~  psql test_db
psql: FATAL:  database "test_db" does not exist
➜  ~
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Okay, we&amp;#8217;ll now install the library that will allow Ruby to talk to PostgreSQL.&lt;/p&gt;


	&lt;p&gt;Just run: &lt;code&gt;sudo gem install pg&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;&lt;img src="http://img.skitch.com/20100208-b4cf1pm1utkf2ihd9up432etwm.jpg" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;Voila&amp;#8230; let&amp;#8217;s move on to the inferior database&amp;#8230;&lt;/p&gt;


	&lt;h3&gt;MySQL&lt;/h3&gt;


	&lt;p&gt;We&amp;#8217;re going to run through the installation of MySQL really quickly because you might need it.&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;sudo port install mysql5 mysql5-server&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;This took ages on my machine&amp;#8230; so let&amp;#8217;s watch a video.&lt;/p&gt;


&lt;object width="560" height="340"&gt;&lt;param name="movie" value="http://www.youtube.com/v/LOZIjWJpiBk&amp;#38;hl=en_US&amp;#38;fs=1&amp;#38;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/LOZIjWJpiBk&amp;#38;hl=en_US&amp;#38;fs=1&amp;#38;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"&gt;&lt;/embed&gt;&lt;/object&gt;

	&lt;p&gt;We&amp;#8217;ll now setup the database and make sure it starts on system boot.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
 sudo -u _mysql mysql_install_db5
 sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
 sudo launchctl start org.macports.mysql5
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Let&amp;#8217;s test that we can create a database now (and that it&amp;#8217;s running.)&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
 ➜  ~  mysql5 -u root
 Welcome to the MySQL monitor.  Commands end with ; or \g.
 Your MySQL connection id is 3
 Server version: 5.1.43 Source distribution

 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 mysql&amp;gt; create database test1;
 Query OK, 1 row affected (0.00 sec)

 mysql&amp;gt; \q
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Great, we&amp;#8217;ll now install the library that will allow Ruby to talk to MySQL.&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;sudo gem install mysql -- --with-mysql-config=/opt/local/lib/mysql5/bin/mysql_config&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;That should be it!&lt;/p&gt;


	&lt;h3&gt;Phase Four, next steps&lt;/h3&gt;


	&lt;p&gt;Okay&amp;#8230; so we&amp;#8217;ve installed XCode, MacPorts, Ruby, Rails, PostgreSQL, MySQL&amp;#8230; and I&amp;#8217;ve also got you to switch your default terminal shell from bash to zsh. You might take a look over the &lt;a href="http://wiki.github.com/robbyrussell/oh-my-zsh/themes"&gt;available themes for Oh My Zsh&lt;/a&gt; so that you can personalize your terminal experience even further.&lt;/p&gt;


	&lt;p&gt;You also now have a handful of gems installed as you can see with &lt;code&gt;gem list&lt;/code&gt;.&lt;/p&gt;


	&lt;p&gt;&lt;img src="http://img.skitch.com/20100208-p2kkjnng2b2kebeenkwkihn2p5.jpg" alt="" /&gt;&lt;/p&gt;


	&lt;h3&gt;Closing thoughts&amp;#8230;&lt;/h3&gt;


	&lt;p&gt;This is the fourth version of this guide and I&amp;#8217;ve appreciated the hundreds of comments, questions, and emails that I have received&amp;#8230; let&amp;#8217;s not forget all those beers that people buy me when I&amp;#8217;m at conferences. :-)&lt;/p&gt;


	&lt;p&gt;I hope you have found some of this useful. If you have any problems and/or questions, don&amp;#8217;t hesitate to post them in the comments section below.&lt;/p&gt;
</description>
      <pubDate>Mon, 08 Feb 2010 13:14:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:2387d63c-c145-4f7e-ad77-e3aa9aabacef</guid>
      <author>Robby Russell</author>
      <link>http://www.robbyonrails.com/articles/2010/02/08/installing-ruby-on-rails-passenger-postgresql-mysql-oh-my-zsh-on-snow-leopard-fourth-edition</link>
      <category>Business</category>
      <category>Ruby on Rails</category>
      <category>Ruby</category>
      <category>Programming</category>
      <category>PostgreSQL</category>
      <category>PLANET ARGON</category>
      <category>rubyonrails</category>
      <category>github</category>
      <category>ohmyzsh</category>
      <category>zsh</category>
      <category>postgresql</category>
      <category>mysql</category>
      <category>rails</category>
      <category>ruby</category>
      <category>xcode</category>
      <category>snowleopard</category>
      <category>osx</category>
      <category>guide</category>
    </item>
  </channel>
</rss>
