First we need to update the repositories.
sudo apt-get update
It’s always a best practice to upgrade the system.
sudo apt-get dist-upgrade
This installation will take few minutes and also require approximately 100 MB disk space.
Now that we are up to date. Let’s start install the RoR recipices. We need following Rails prerequisites.
- ruby - An interpreter of object-oriented scripting language Ruby
- ri - Ruby Interactive reference
- rdoc - Generate documentation from ruby source files
- irb - Interactive Ruby
sudo apt-get install ruby ri rdoc irb libopenssl-ruby ruby-dev
Ruby Gem installation
Next we need to install the Ruby gem package manager. You can download the latest Ruby gems by following link.
Download and extract the files. (By the time I’m writing this tutorial the latest version is 1.3.5)
tar xvzf rubygems-1.3.5.tgz
sudo ruby setup.rb
Once it’s done you can delete the .tgz file and rubygems directory.
rm -r rubygems-1.3.5 rubygems-1.3.5.tgz
Next we need to create a set of simlinks. Otherwise it will be a tedious task to type commands with the version (1.8). For an example if we need to call the gem command we’ve to type gem1.8. I don’t prefer that. Hope you too. So, let’s create the necessary simlinks.
sudo ln -s /usr/bin/gem1.8 /usr/local/bin/gem
sudo ln -s /usr/bin/ruby1.8 /usr/local/bin/ruby
sudo ln -s /usr/bin/rdoc1.8 /usr/local/bin/rdoc
sudo ln -s /usr/bin/ri1.8 /usr/local/bin/ri
sudo ln -s /usr/bin/irb1.8 /usr/local/bin/irb
Now we can install Rails using gem.
sudo gem install rails
Rails by default comes with the WEBrick server. But most Rails developers prefer the Mongrel server. If you satisfied with WEBrick you can skip this step, else type the following command to install Mongrel server.
sudo gem install mongrel
Rails 2.3 shipped with SQLite3 as it’s default database instead of MySQL. You can install SQLite3 libraries by following commands.
sudo apt-get install sqlite3 swig libsqlite3-ruby libsqlite3-dev
sudo gem install sqlite3-ruby
If you prefer MySQL,
sudo apt-get install mysql-client libmysqlclient15-dev
sudo gem install mysql
Create Ruby on Rails App
Now that we have completed everything successfully. You can create your new Ruby on Rail applicaion by following command.
If you need MySQL supported applicaion you need to specify as follows
rails test-app -d mysql
Run the app
navigate you browser to http://localhost:3000