This post has moved over to my new home. blog.dnite.org. Head over there for any updates or whatever.
It seems as though all the information for getting a full Ruby on Rails system up and running in Ubuntu is pretty scattered about the web, so I thought this makes a perfect opportunity to go ahead and condense it all in one place. From start to finish.. Here we go..
Install Ruby
First we need to install ruby and a few extra things so we don’t have issues later. just installing ruby will work to some degree, but things will break later.
sudo apt-get install ruby ruby1.8 ruby1.8-dev rdoc ri irb
Install MySQL
A lot of Rails folks like to use sqlite.. i haven’t tested it but I believe that’s as easy as ’sudo apt-get install sqlite3′. Could involve more steps though. Here’s what I did to install MySQL.
sudo apt-get install mysql-server libmysql-ruby
Then, just to be safe, lets add a password for root.
mysqladmin -u root password NEW_PASSWORD
sudo /etc/init.d/mysql restart
You may want to go ahead and create your databases now, or save it for later…
mysql -u root -p
Install Ruby Gems
Ruby Gems will install a majority of Rails and any other cool stuff we need specific to Ruby. There’s no package of it availiable for ubuntu (as of right now) so you’ll have to download it yourself. The current version as of today is 0.9.0, but make sure that’s the most current version before following the steps below exactly by going to http://rubyforge.org/frs/?group_id=126. If it’s not, then just replace the url below with the url to the most current version.
wget http://rubyforge.org/frs/download.php/11289/rubygems-0.9.0.tgz
tar zxvf rubygems-0.9.0.tgz
cd rubygems-0.9.0
sudo ruby setup.rb
Install Rails
Next it’s time to install Rails. If you followed all the directions till now, it shouldn’t be a problem. I have run into the problem of rdoc spilling out a bunch of errors if you failed to install that. I’ve also read that you have to be in your home dir to perform this step. Not sure if that’s true, but it couldn’t hurt.
cd
sudo gem install rails –include-dependencies
Install an IDE (optional)
You should now have a fully operational Ruby on Rails install right now. The next step would be to choose how you want to work on your web applications. Linux has a whole slew of editors you can use. Vim is a popular choice among the rails novices. If your looking for something a little more user friendly and easy to get into, RadRails is very nice for this. There is no package for RadRails, but lucky enough, RadRails is enclosed in a single folder you can toss just about anywhere and run from there. I extracted it to /opt/radrails and created a small file to run it in /usr/bin… This is all completely up to you. However you feel most comfortable working.
EDIT: I actually did a new piece on using Vim as your ‘IDE’ for rails. Take a look.
Install RMagick (optional)
Another problem I ran into was getting ImageMagick and RMagick installed and working right in ubuntu. If you will be needing photo manipulation support for your web app, use these instructions for installing RMagick.
sudo apt-get install imagemagick
dpkg -l | grep magick
You will see a list of the imagemagick packages that were installed. There should be one that starts with lib and ends with a number. Mine was libmagick9, so below, if you have anything but libmagick9, replace the number below.
sudo apt-get install libmagick9-dev
sudo gem install rmagick
rmagick takes a little while to build. So go grab something to eat or drink.
Conclusion
Looking back, getting Ruby on Rails is not all that hard to do in ubuntu, but having information that was either old or scattered in many places made it a pain in the ass for me. So I hope someone comes across it helps them out a bit. I’m pretty sure I got all the instructions right, but if something happens to not work, leave a comment and I’ll try and help.
EDIT:
It would figure that the first day that wiki.rubyonrails.com is down in.. forever? is the day that I chose to try and install rails on ubuntu myself. Most of this information is up there, but I went ahead and added the last part about image magick there, So check out wiki.rubyonrails.com.. You can get just about anything there. x=)