Apr 16, 2007

Installing Ruby on Rails


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.2, 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.2.tgz
tar zxvf rubygems-0.9.2.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 -y



This should get you running, however you need to install Apache or lighthttpd to host your rails application.

No comments: