dnite’s ‘old’ Blog

For my new blog, head over to http://blog.dnite.org

  • Moved Out!

    Thanks for stopping by my blog! It's been fun over here at Wordpress.com but I've moved to bigger, better things. My new blog is located here! Hope to see you there!

  • Advertisements

Ruby on Rails on Ubuntu

Posted by dnite on October 24, 2006

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.

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.


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.

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=)


14 Responses to “Ruby on Rails on Ubuntu”

  1. Chris said

    Sweet instructions … appreciate it!

  2. […] I wrote an article not too long ago about installing Ruby on Rails on Ubuntu (Edgy) quickly and easily. The one section I left pretty ‘in the air’ was definately the IDE. I feel that Linux has the biggest choice when it comes to editor options. […]

  3. Ruby On Rails, installation sous Ubuntu

    Suite à mon premier article sur Ruby On Rails voici comment l’installer sous Ubuntu.Installer ruby et ses dépendances.sudo apt-get install rubyTélécharger RubyGems le gestionnaire de paquetage pour ruby.Décompresser l’archive téléchargée se p…

  4. […] Ruby-on-Rails on Ubuntu […]

  5. Vish said

    Thanks a bunch for your effort.

    It all worked smoothly except for some message while installing rmagick:

    sh:wmf2eps command not found

    The gem install still ended saying “Successfully installed rmagick..” and I see rmagick in output of ‘gem list –local’.

  6. When I execute sudo apt-get install libmagick9-dev it asks me to remove xserver-xorg. I’m using Xubuntu and the last time I did that, my GUI was gone.

    Is there a way around removing this package?

  7. dnite said


    I have yet to come across that problem. I haven’t used Xubuntu, but I can’t imagine why those 2 packages would have anything to do w/ each other. If you remove xserver-xorg, you will indeed lose your GUI… Hit up the #ubuntu irc channel on freenode.net, or file a bug report for Xubuntu because that just seems weird to me and I’m not sure how to get around that… Sorry…

  8. philip said

    Somehow, rails isn’t happy on my eft laptop despite doing exactly what you describe above (which did work with appropriate replacements on my opensuse 10.2 server). Well, rails works, but then bombs when you try to generate scaffolding thusly:
    philip@gus:~/workspace/gnarlyvines/winehandler$ ./script/generate scaffold appellation appellation
    exists app/controllers/
    exists app/helpers/
    create app/views/appellation
    exists app/views/layouts/
    exists test/functional/
    dependency model
    exists app/models/
    exists test/unit/
    exists test/fixtures/
    create app/models/appellation.rb
    create test/unit/appellation_test.rb
    create test/fixtures/appellations.yml
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/mysql_adapter.rb:389: [BUG] Segmentation fault
    ruby 1.8.4 (2005-12-24) [i486-linux]

    Ouch! Any ideas?

  9. Thank you for the instructions. Helped avoid a headache. Kek!

  10. bogdan said

    thanks … many thanks man 🙂 … I just got myself to Feisty and lost most of the settings 😦 … you saved me a lot of time … thanks again 🙂

  11. hero1971 said

    when i try to run sudo ruby setup.rb, it gave me :

    /usr/local/lib/ruby/site_ruby/1.8/rubygems/remote_fetcher.rb:4:in `require’: no such file to load — zlib (LoadError)
    from /usr/local/lib/ruby/site_ruby/1.8/rubygems/remote_fetcher.rb:4
    from /usr/local/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:8
    from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:504
    from /home/jiheng/rubygems-0.9.4/./post-install.rb:81:in `install_sources’
    from /home/jiheng/rubygems-0.9.4/./post-install.rb:116:in `run_hook’
    from setup.rb:1526:in `exec_task_traverse’
    from setup.rb:1342:in `exec_install’
    from setup.rb:1000:in `exec_install’
    from setup.rb:814:in `invoke’
    from setup.rb:773:in `invoke’
    from setup.rb:1578

  12. Andy said

    Cheers, that helped a fair bit with Rmagick 🙂

  13. Aeshan said

    I installed RubyGems, but I cant seem to use it.keep getting this error:
    aeshan@aeshan-desktop:~$ sudo gem install mongrel
    /usr/bin/gem:23: uninitialized constant Gem::GemRunner (NameError)

    Any hints on whats wrong?

  14. Scary said

    thx alot for this instruction set!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: