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

Download ruby sources:

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

then

$ tar xzf stable-snapshot.tar.gz

Compiling and installing

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

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 Paco

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/45905/rubygems-1.3.2.tgz
$ tar xzvf rubygems-1.3.2.tgz
$ cd rubygems-1.3.2
$ 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.

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

gui, 2009/04/11 13:40

I think it would help to explain how to remove ruby and gems when installed from sources in order to have a clean start if needed. I would write the instructions but actually I don't know how to do it :)

Eric J. Gruber, 2009/04/25 20:17

I installed RoR on a new install of Ubuntu 9.04 today. Everything ran smoothly using these instructions except for two things.

1. Installing rubygems using tar xzvf rubygems-1.3.2.tgz didn't work for me. Instead I used Ubuntu's archive manager to extract the files that wget downloaded. For those having problems with wget, just download the tarball straight from rubyforge then use the archive manager.

2. After getting Rails running, I was unable to migrate an sqlite3 database. I noticed this error message in the logs: rake aborted! no such file to load – sqlite3. I had sqlite3, so what to do? I needed the ruby library to go with it. I ran sudo apt-get install libsqlite3-ruby, then everything worked fine.

João Pedro Morais, 2009/04/27 08:40

Is it possible to install rails on a server that can only be accessed by FTP and that has already ruby, apache and mySQL installed?

hubbub, 2009/06/18 04:22

I was also getting this error message, MissingSourceFile: no such file to load – sqlite3,

installing the lib worked for me too, following Eric Gruber's advice above.

sudo apt-get install libsqlite3-ruby

 
getting-started/installation/linux.txt · Last modified: 2009/04/19 00:53 by sudipta
 
Recent changes RSS feed Creative Commons License