How to Install Ruby on Rails on Debian Squeeze

I was looking for a nice and clean way to install Ruby on Rails on a Debian Squeeze server, but couldn’t really find anything that actually worked. Most of the information I saw wanted you to compile gems by source and I tried that, but it didn’t work. Then I looked for the gems package from Debian, and tried installing that. It worked like a charm.

Here’s the commands I used:

sudo apt-get install ruby
sudo apt-get install rubygems
gem install rails

Note: as of today (10/15/11) apt-get install ruby installs version 1.8.7. Also, installing rails takes forever so be prepared for that.

Also, rails is located at:

/var/lib/gems/1.8/bin