Posted By Slobodan Kovacevic on July 2, 2006
Recently I started messing around with Ruby and I wanted to set it up on our local server, so I gave InstantRails a go – and it worked perfectly.
Meanwhile we changed our operating system and switched from Windows to Linux (Ubuntu Dapper), so now I needed Rails for Ubuntu. Unfortunately (or luckily) there is no InstantRails for Ubuntu. The only way to go was to install “real” Ruby and Rails, so I had to figure out how to install it once again.
Again I tried to find a meaningful and complete tutorial, but I didn’t found it so I had to glue pieces from different sources (you have a complete list of articles I used at the end). I wanted to do this as simple as possible and without any compiling.
Install Ruby and Ruby On Rails packages
There are quite a few packages you need to install and the easiest way to do that is to use Synaptic package manager, but if you prefer you can use apt-get or anything else you fancy. Before you continue make sure that you have enabled Universe repository (how to add repositories), otherwise some of the packages might not show up.
You need to install following packages as well as all dependencies for them (Synaptic will let you know if some package needs additional packages):
- ruby1.8 – installs Ruby 1.8.4
- libmysql-ruby – additional libraries to access MySQL
- libopenssl-ruby – adds SSL capability to Ruby
- libruby1.8-dbg – debugging library
- ri – Ruby Interactive Reference
- ruby1.8-dev – header files for building extensions
- rails – Ruby On Rails framework
When you install all of those you should be able to go to terminal and check if Ruby is properly installed. Just type ruby -v and you should see something like this:
ruby 1.8.4 (2005-12-24) [x86_64-linux]
You can also try a simple command line program like:
Next you would need RubyGems which is kind of package manager for Ruby. You will need it to get additional (3rd party) Ruby scripts such as Rails. There is no Ubuntu package for RubyGems so you have to install it manually.
You need to download latest version of RubyGems from RubyForge and unpack it anywhere you like. Then in terminal go to that dir and type:
sudo gem install rubygems-update
sudo gem install rails –include-dependencies
This will install RubyGems, update it, install rails and all required gems/packages (just answer to all dependency questions with yes).
Testing Rails by building lame Hello World app
To create a sample Ruby app you need to type following to terminal (providing that you are in a dir where you want to place hello app):
This will create a new application in hello dir and will start Webrick server (development web server for Ruby). Now if you go to http://0.0.0.0:3000 you should see Rails welcome page.
The final test is to create a proper Hello World app, that is you need to generate a ‘hello’ controller. You can do that by going to hello dir and typing:
and then editing file hello/app/controllers/hello_controller.rb to look like this:
render_text "Lame Hello World"
Finally, start Webrick once again (type: ruby script/server) and point your browser to http://0.0.0.0:3000/hello and that’s it.
This setup isn’t perfect, but for a single developer it would do just fine. My next task is to configure Webrick a bit more (for example, make it available for other people in my network to access it) or to make Rails work through my existing Apache (although it seems that it isn’t suitable for development as it caches Ruby pages).
You may also be interested to look at these: