<?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>Raymond Law: Setting up Ruby on Rails, MySQL, Mongrel, memcached, and RMagick using MacPorts on Mac OS X 10.5 Leopard</title>
    <link>http://blog.rayvinly.com/articles/2007/11/29/setting-up-ruby-on-rails-with-mysql-on-mac-os-x-10-5-leopard</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Setting up Ruby on Rails, MySQL, Mongrel, memcached, and RMagick using MacPorts on Mac OS X 10.5 Leopard</title>
      <description>&lt;p&gt;I recently got the new Santa Rosa Macbook with &lt;a href="http://www.apple.com/macosx/"&gt;Leopard&lt;/a&gt; pre-installed and I need to set up the Rails development environment.&lt;/p&gt;


	&lt;p&gt;Basically there are 3 ways to achieve that:&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;1. Locomotive&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://locomotive.raaum.org/"&gt;Locomotive&lt;/a&gt; method is simple and self contained.  It works very well for Mac &lt;span class="caps"&gt;OS X 10&lt;/span&gt;.4 Tiger.  However, the author acknowledges that Locomotive  &lt;a href="http://sourceforge.net/forum/forum.php?thread_id=1858643&amp;#38;forum_id=491804"&gt;may not be Leopard ready&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;2. Rails comes with Leopard&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;That&amp;#8217;s right.  Apple has included Rails by default, as noted by &lt;a href="http://weblog.rubyonrails.org/2007/10/26/today-is-leopard-day"&gt;&lt;span class="caps"&gt;DHH&lt;/span&gt;&lt;/a&gt;.  This sounds great.  However, that means you will also have to manually install Imagick, RMagick, and all those other stuff that you need for development.  Also, it may be harder to upgrade Ruby or Rails when new versions come out.  You probably need to install from source to upgrade or what not&amp;#8230;&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;3. MacPorts&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;You might already have your Rails environment set up using &lt;a href="http://www.macports.org/"&gt;MacPorts&lt;/a&gt;.  If that&amp;#8217;s the case, why not just use that?  Even if you are like me with a fresh installed Leopard, MacPorts still has its advantages.  For example, you can use MacPorts to upgrade ruby in the future.&lt;/p&gt;


	&lt;p&gt;I used MacPorts to set up my Rails environment based on these other great articles:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;a href="http://teabass.com/super-simple-ruby-on-rails-install-with-macports-for-leopard/"&gt;Teabass&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://www.robbyonrails.com/articles/2007/06/19/installing-ruby-on-rails-and-postgresql-on-os-x-second-edition"&gt;Robby on Rails&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://michael.biven.org/2006/12/22/starting-mongrel-or-memcached-with-launchd/"&gt;Michael Biven&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://gorn.ch/archive/2007/01/22/start-memcached-with-launchd.html"&gt; Tobias Ebn&#246;ther&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;1. Install the latest Xcode version for Leopard.  &lt;a href="http://developer.apple.com/tools/download/"&gt;Download&lt;/a&gt; from the Apple website.&lt;/p&gt;


	&lt;p&gt;2. Install the latest MacPorts version for Leopard.  &lt;a href="http://www.macports.org/"&gt;Download&lt;/a&gt; from the MacPorts website.&lt;/p&gt;


	&lt;p&gt;Run this to update MacPorts:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;sudo port selfupdate&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;3. Install Ruby, RubyGems, and Rails.&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;sudo port install ruby
sudo port install rb-rubygems
sudo gem update --system
sudo gem install rails -y&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;4. Install MySQL (directly from Andrew Nesbitt, shown here for completeness).&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;sudo port install mysql5 +server
sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
sudo -u mysql mysql_install_db5
cd /opt/local ; sudo /opt/local/lib/mysql5/bin/mysqld_safe &amp;amp;
sudo ln -s /opt/local/var/run/mysql5/mysqld.sock /tmp/mysql.sock&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;5. Install mongrel and mongrel_cluster.&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;sudo gem install mongrel
sudo gem install mongrel_cluster&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;6. Install memcached.&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;sudo port install memcached
sudo gem install memcache-client&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;Create a file called /Library/LaunchDaemons/com.danga.memcached.plist, and insert the following:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;
&amp;lt;!DOCTYPE plist PUBLIC &amp;quot;-//Apple//DTD PLIST 1.0//EN&amp;quot; &amp;quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&amp;quot;&amp;gt;
&amp;lt;plist version=&amp;quot;1.0&amp;quot;&amp;gt;
&amp;lt;dict&amp;gt;
        &amp;lt;key&amp;gt;Label&amp;lt;/key&amp;gt;
        &amp;lt;string&amp;gt;com.danga.memcached&amp;lt;/string&amp;gt;
        &amp;lt;key&amp;gt;OnDemand&amp;lt;/key&amp;gt;
        &amp;lt;false/&amp;gt;
        &amp;lt;key&amp;gt;ProgramArguments&amp;lt;/key&amp;gt;
        &amp;lt;array&amp;gt;
                &amp;lt;string&amp;gt;/opt/local/bin/memcached&amp;lt;/string&amp;gt;
                &amp;lt;string&amp;gt;-d&amp;lt;/string&amp;gt;
                &amp;lt;string&amp;gt;-m&amp;lt;/string&amp;gt;
                &amp;lt;string&amp;gt;64&amp;lt;/string&amp;gt;
                &amp;lt;string&amp;gt;-u&amp;lt;/string&amp;gt;
                &amp;lt;string&amp;gt;www&amp;lt;/string&amp;gt;
                &amp;lt;string&amp;gt;-p&amp;lt;/string&amp;gt;
                &amp;lt;string&amp;gt;11211&amp;lt;/string&amp;gt;
        &amp;lt;/array&amp;gt;
        &amp;lt;key&amp;gt;RunAtLoad&amp;lt;/key&amp;gt;
        &amp;lt;true/&amp;gt;
&amp;lt;/dict&amp;gt;
&amp;lt;/plist&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;In order to launch memcached on boot, enter this in the terminal:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;sudo launchctl load -w /Library/LaunchDaemons/com.danga.memcached.plist&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;7. Install ImageMagick and RMagick&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;sudo port install ImageMagick
sudo gem install rmagick&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;&lt;strong&gt;&lt;span class="caps"&gt;NEW&lt;/span&gt;!&lt;/strong&gt; There are now &lt;a href="http://rmagick.rubyforge.org/install-osx.html"&gt;instructions&lt;/a&gt; on how to install ImageMagick and RMagick.&lt;/p&gt;


	&lt;p&gt;8. &lt;em&gt;Optional&lt;/em&gt; &amp;#8211; I found out if you have the loaded_plugins gem installed, you may see the following error when running script/console:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;/opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:477:in `const_missing':NameError: uninitialized constant Gem::Version::NUM_RE&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;The reason is MacPorts create two directories to store the RubyGems stuff in /opt/local/lib/ruby/site_ruby and /opt/local/lib/ruby/vendor_ruby.  Ruby&amp;#8217;s $LOAD_PATH looks in site_ruby first but the version.rb in site_ruby does not define Gem::Version::NUM_RE whereas the version.rb in vendor_ruby does.  I&amp;#8217;ve outlined the issue &lt;a href="http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/484e09d92b2d9db4#a9adf1301cb66fc1"&gt;here&lt;/a&gt;. So I simply swap them:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;sudo mv /opt/local/lib/ruby/site_ruby /opt/local/lib/ruby/vendor_ruby_tmp
sudo mv /opt/local/lib/ruby/vendor_ruby /opt/local/lib/ruby/site_ruby
sudo mv /opt/local/lib/ruby/vendor_ruby_tmp /opt/local/lib/ruby/vendor_ruby&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;This fixes the error and everything runs well for me, but I would like to hear the experts out there about why there are separate vendor_ruby and site_ruby.&lt;/p&gt;


	&lt;p&gt;That&amp;#8217;s it.  Hope you find this helpful and please report any problems.&lt;/p&gt;</description>
      <pubDate>Thu, 29 Nov 2007 03:30:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:66dd5743-3a59-4eae-85e9-27025ffb623f</guid>
      <author>Raymond Law</author>
      <link>http://blog.rayvinly.com/articles/2007/11/29/setting-up-ruby-on-rails-with-mysql-on-mac-os-x-10-5-leopard</link>
      <category>Apple</category>
      <category>Ruby on Rails</category>
      <category>Mac</category>
      <category>Web 2.0</category>
      <category>ruby</category>
      <category>rails</category>
      <category>rubyonrails</category>
      <category>apple</category>
      <category>mac</category>
      <category>macosx</category>
      <category>leopard</category>
      <category>macbook</category>
      <category>macports</category>
      <trackback:ping>http://blog.rayvinly.com/articles/trackback/37</trackback:ping>
    </item>
    <item>
      <title>"Setting up Ruby on Rails, MySQL, Mongrel, memcached, and RMagick using MacPorts on Mac OS X 10.5 Leopard" by Si Tokumine</title>
      <description>&lt;p&gt;Just a quick heads up for those developers not wanting to run memcached permanently on their machines. You can simply run it from the command line using:&lt;/p&gt;


&lt;pre&gt;
/opt/local/bin/memcached -d -m 64 -u www -l &amp;lt;yourIP&amp;gt; -p 11211
&lt;/pre&gt;

	&lt;p&gt;&lt;br&gt;&lt;br&gt;
Alternatively, just download the &lt;a href="http://github.com/defunkt/cache_fu" rel="nofollow"&gt;cache_fu&lt;/a&gt; plugin and use the  free memcached_ctl command it gives you (written by atmos):&lt;/p&gt;


&lt;pre&gt;
# script/memcached_ctl stop
# script/memcached_ctl start
# script/memcached_ctl status
&lt;/pre&gt;
&lt;br&gt;
to start, stop and monitor the status of your local memcache setup.</description>
      <pubDate>Tue, 29 Apr 2008 09:37:23 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:c76a7302-72ef-44f3-89b3-522ea1bf3625</guid>
      <link>http://blog.rayvinly.com/articles/2007/11/29/setting-up-ruby-on-rails-with-mysql-on-mac-os-x-10-5-leopard#comment-6561</link>
    </item>
    <item>
      <title>"Setting up Ruby on Rails, MySQL, Mongrel, memcached, and RMagick using MacPorts on Mac OS X 10.5 Leopard" by Stefan</title>
      <description>&lt;p&gt;nevermind, I created it.&lt;/p&gt;</description>
      <pubDate>Sat, 26 Jan 2008 20:08:30 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:d296c017-65ec-47d6-9c05-04bb1e7619db</guid>
      <link>http://blog.rayvinly.com/articles/2007/11/29/setting-up-ruby-on-rails-with-mysql-on-mac-os-x-10-5-leopard#comment-2624</link>
    </item>
    <item>
      <title>"Setting up Ruby on Rails, MySQL, Mongrel, memcached, and RMagick using MacPorts on Mac OS X 10.5 Leopard" by Stefan</title>
      <description>&lt;p&gt;The second part of step 6 does not work, I cant seem to create the Plist file in the Property List Editor. any ideas?&lt;/p&gt;</description>
      <pubDate>Sat, 26 Jan 2008 20:01:23 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:a86e75d1-7c9b-47c4-a8f6-191603fdb60f</guid>
      <link>http://blog.rayvinly.com/articles/2007/11/29/setting-up-ruby-on-rails-with-mysql-on-mac-os-x-10-5-leopard#comment-2623</link>
    </item>
    <item>
      <title>"Setting up Ruby on Rails, MySQL, Mongrel, memcached, and RMagick using MacPorts on Mac OS X 10.5 Leopard" by Raymond Law</title>
      <description>&lt;p&gt;depi, &lt;a href="http://dev.mysql.com/doc/refman/5.0/en/problems-with-mysql-sock.html" rel="nofollow"&gt;this&lt;/a&gt; may help you.&lt;/p&gt;


	&lt;p&gt;But the MySQL socket is actually in /opt/local/var/run/mysql5/mysqld.sock, so I think if you have this, you should be fine.  Is MySQL server running on your machine?  Do:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;ps -ef | grep mysql&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Do you see it running?  Can you connect to it?&lt;/p&gt;</description>
      <pubDate>Wed, 19 Dec 2007 15:23:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:d9f19edb-a46e-47a4-9ac7-9573c0bd85d1</guid>
      <link>http://blog.rayvinly.com/articles/2007/11/29/setting-up-ruby-on-rails-with-mysql-on-mac-os-x-10-5-leopard#comment-1067</link>
    </item>
    <item>
      <title>"Setting up Ruby on Rails, MySQL, Mongrel, memcached, and RMagick using MacPorts on Mac OS X 10.5 Leopard" by depi</title>
      <description>&lt;p&gt;Hello,&lt;/p&gt;


	&lt;p&gt;Thanks for that post, it is very useful for me as I&amp;#8217;m new to Mac OS and I wanted to install all those things there.&lt;/p&gt;


	&lt;p&gt;I think I don&amp;#8217; understand is that whenever I restart my computer, the file /tmp/mysql.sock is gone and I must to create again the symbolic link. Do you have any recommendations or solution for this problem?&lt;/p&gt;


	&lt;p&gt;Thanks.&lt;/p&gt;</description>
      <pubDate>Mon, 17 Dec 2007 11:23:09 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:bf03f2e7-56eb-4ba8-8a3f-5efb69698d40</guid>
      <link>http://blog.rayvinly.com/articles/2007/11/29/setting-up-ruby-on-rails-with-mysql-on-mac-os-x-10-5-leopard#comment-1005</link>
    </item>
  </channel>
</rss>
