Saturday, 9 June 2007

Get Ruby + Rails + Mongrel working on Ubuntu

I experienced several tricky little problems when I was trying to get Ruby installed on my home development machine and after spending a few hours sorting them, I thought that I would consolidate my thoughts into one place so I wouldn't forget them. Also, maybe this will help someone else following along.

First, this works for Ubuntu (and probably Debian) Linux, so if you're here with a Windows machine then you're probably not going to get too much out of this.

Also, these commands assume that you're using an interactive root terminal (accessed with sudo -i from a terminal session). If you're not happy with doing this then you could just prefix everything with "sudo" and you'll get the same effect.

So, on with the show. First we simulate the process of getting Ruby 1.8 onto your system so you can check for kernel problems.

apt-get update
apt-get -s -t testing install ruby irb rdoc ri ruby1.8-dev libzlib-ruby libopenssl-ruby1.8

If you see this message coming back at you

The following packages will be REMOVED:
base-config initrd-tools kernel-image-2.6.8-2-386

then you're in a spot of trouble and you'll need to do some kernel magic. Most people will not and can continue with this sequence...

Do pretty much the same thing as above, but not in simulation mode.

apt-get update
apt-get -t testing install ruby irb rdoc ri ruby1.8-dev libzlib-ruby libopenssl-ruby1.8

Install gems to get access to those nifty extras that save sooo much time

apt-get install rubygems

Now install the various build libraries that'll make sure that those gems you'll be getting later will build properly when you install them later on.

apt-get install build-essential

And finally install those lovely core gems that we can't live without. This will put mongrel and mongrel_cluster (ideal for real world deployment) onto your system. Also, capistrano is brilliant for handling the actual deployment process. Mysql for providing high quality but simple SQL db access. Trestle replaces scaffold in producing production ready controllers that are more secure.

gem install actionpack actionwebservice activerecord activesupport capistrano cgi_multipart_eof_fix daemons fastthread fcgi gem_plugin login_generator mongrel mongrel_cluster mysql needle net-ssh net-sftp rake sources termios trestle_generator

So there you have it. By now your installation should be working.

No comments: