Installing Ubuntu Feisty Fawn on Virtual PC to Run Ruby on Rails

This post follows a 14 hour struggle to get Rails going on my Windoze Vista and my Windoze XP machine. I’ve been doing PHP development for a little while now, and have been using Xampp on both of my machines to create a local server for web-development. Recently we made a decision to build one of our in-house sites with Ruby on Rails, to take advantage of its agile nature, plugin modules, and overall speed of development. Boy was I in for a surprise.

Apparently, you cannot install Instant Rails, unless you want to try to figure out how to merge your 2 instances of Apache, and MySQL that are now running. In my hours of hunting, I could not come across a Rails plugin for Xampp. I tried to do a stand-alone rails install, and manually configure it, but then I could not use localhost for anything other than Ruby. This whole time, all I can think is that if I only had a Mac… but wait, I have an idea.

I’m a big fan of Windows Virtual PC 2007, so why not try to just set-up a Virtual Linux instance, and . Plus, once I get it set up, I can copy the Virtual PC hard-drive, and pass it around the office to everyone having the same problem I am.. BRILLIANT. For the record, I am writing this as I do it, so if I encounter FAIL, I’ll retitle, and post this in hopes someone can help.

Step 1Install Virtual PC 2007. This is one of the few free things that Microsoft offers, so I highly recommend you take advantage of it. You will find it to be quite versatile… I like the idea of running everything in a virtual PC, so if I need to buy a new computer, I don’t loose all my software and settings.. I just copy the Virtual Hard Drive, and BAM!, I’m ready to go. I also spec’d a lightweight machine, and copied it over to a thumb drive with a copy of the Virtual PC install file.. now I can load my personal PC on any windows machine.

Step 2Download Ubuntu 7.04 and Create a Virtual Machine. I am using a desktop version of Feisty Fawn, and can vouch that what I lay out here will work for this version only. To keep focus, I’m going to point you to Mike Kolitz for a detailed tutorial to install on Virtual PC. For some reason, some unanswered “issues” are not referenced though, and the answers are spread out, so if you encounter problems with video resolution, sound, networking (first click network, then wired), mouse, or system time < — check out the links. Please note – the install process takes about an hour, so try going for a jog, or pancakes..or both!

I edited the settings for my Virtual Machine to enable an “undo” function for the virtual drive. This way I could play with some of these “fixes” without worry of putting myself back to zero. When I make a system configuration change and it is successful, I go to the action menu, select close, and then select save state save changes (so I don’t have to wait on a reboot).

(Optional) Do a quick check for updates by going to terminal and typing (without quotes) “sudo apt-get update && sudo apt-get upgrade”. This will probably take a little while, so go grab a bottle of wine or a few beers and start drinking!

Step 3Install LAMP – Thanks to Joe Raad for the wonderful walk-through. If you follow his instructions, you’ll have no problem, and you get the benefit of installing through apt-get vs. some package, which is one of many AWESOME Linux functions. Unlike Windows, Linux uses the apt-get function to update not only your OS, but also all of the programs.. pretty sweet! We’ll try it out once we wrap up the Ruby install.

Step 4 – Install Ruby on Rails –

-Start with Ruby using apt-get  (all on one line)

~$ sudo apt-get install apt-get install ruby rdoc irb libyaml-ruby
libzlib-ruby ri libopenssl-ruby ruby1.8-dev build-essential

-Install Gems from source (we are not using apt-get here because Gems updates itself and Rails, and we don’t want to confuse apt-get

~$ wget http://rubyforge.org/frs/download.php/34638/rubygems-1.1.0.tgz
~$ tar -xvzf rubygems-1.1.0.tgz
~$ rm rubygems-1.1.0.tgz
~$ cd rubygems-1.1.0
~$ sudo ruby setup.rb

-Allow Ruby Gems to update itself (and make sure gem installed properly)

~$ sudo gem update --system

If you get a gem: command not found error.. create a symbolic link by executing this:

~$ sudo ln -s /usr/bin/gem1.8 /usr/bin/gem

-Now, we install Rails using Ruby Gems

~$ sudo gem install rails
~$ PATH=${PATH}:/var/lib/gems/1.8/bin/
~$ export PATH

-Add the Driver for MySQL

~$ sudo apt-get install libmysql-ruby

Alright, now that the grunt work is over, you can start building some applications. Have fun!


Update 05/03/08

I finally got it working on Windows – check it out


Update 04/15/09

If I want to use Ruby on Rails (ROR) I dual boot to Linux vs. fighting to install Rails on Windows machine.

Note: Post is imported from my writings here … there may be some comments there that are helpful!