Translations of this page?:

Installing Ruby on Rails on Debian/Ubuntu

In this tutorial you will install Ruby, RubyGems, and Rails on Debian/Ubuntu.

Install Ruby from repository

$ sudo apt-get install ruby-full build-essential

Install Ruby from source

Prerequisite packages:

$ sudo apt-get install build-essential libssl-dev libreadline5-dev zlib1g-dev checkinstall

Download ruby sources:

$ wget ftp://ftp.ruby-lang.org/pub/ruby/stable-snapshot.tar.gz

then

$ tar xvzf stable-snapshot.tar.gz

Compiling and installing

$ cd ruby/
$ ./configure
$ make
$ sudo checkinstall

Test installation

$ ruby -v

show something like:

ruby 1.8.7p5000 (2009-02-22) [i686-linux]

Test libraries

$ ruby -ropenssl -rzlib -rreadline -e "puts :Hello"

Will show:

Hello

Note: to manage this type of installation you can use aptitude or apt-get.

Install RubyGems

Download the latest version of RubyGems at the Rubyforge RubyGems page.

Rails 2.2.2 requires v1.3.1 or higher.

$ cd ~
$ wget http://rubyforge.org/frs/download.php/57643/rubygems-1.3.4.tgz
$ tar xzvf rubygems-1.3.4.tgz
$ cd rubygems-1.3.4
$ sudo ruby setup.rb
$ sudo ln -s /usr/bin/gem1.8 /usr/bin/gem

Note: It is possible to install RubyGems using apt-get. However, this is not recommended although you can still do it:

$ sudo apt-get install rubygems
$ sudo gem install rubygems-update --version=1.3.4
$ sudo gem install rails
$ rails --version
Rails 2.3.5

Note: Ruby 1.9.1 comes with rubygems.

Install Rails via RubyGems

Once RubyGems is installed, use it to install Rails:

$ sudo gem install rails

Install MySQL DB server (optional)

By default, Rails includes the sqlite3 gem and is automatically configured to use it. To use MySQL instead, follow the following steps:

$ sudo apt-get install mysql-server mysql-client
$ sudo apt-get install libmysql-ruby libmysqlclient-dev
$ sudo gem install mysql

Rails assumes that the MySQL socket file will be found in /tmp/mysqld.sock. In Debian/Ubuntu, this is not the case. Be sure to change database.yml to reflect the actual location of the socket file:

socket: '/var/run/mysqld/mysqld.sock'

Test your Rails installation

To test your Rails installation, generate a new Rails project:

$ rails myrailsapp

If you are using MySQL, use the following command:

$ rails myrailsapp -d mysql

Deployment

Many popular web server configurations are available for Linux. Please see:

Discussion

Eric J. Gruber, 2009/04/28 05:52

Odd. I commented on this and now it's gone. Another comment was on here and it's gone as well.

Umur Ozkul, 2009/05/09 04:40

Just there is an easier way of starting your Ruby life. Tested on Jaunty. http://tinyurl.com/ruby-on-rails-tutorial

Umur Ozkul, 2009/05/13 20:47

Rails 2.3 provides new possibilities. Templates mean faster project initiation. And latest developments of Ubuntu and Rails mean lesser installation.

This tutorial is fully tested on Ubuntu Jaunty: Rais101 Tutorial Ruby on Rails with Relations http://conceptspace.wikidot.com/blog:19

Ubuntu 9.04 Rails 2.3.2

Anton, 2009/06/23 14:55

I strongly recommend to read this howto if you have Debian etch - http://www.offix.ch/Howto-Install-Rails-On-Debian-Etch . The information on the current page didn't work well on etch to me.

 
getting-started/installation/linux-ubuntu.txt · Last modified: 2009/12/07 23:03 by etd
 
Recent changes RSS feed Creative Commons License