You are here:Home » Ruby on Rails » How to install Ruby on Rails 3.2 with SQLite3 on Debian/Ubuntu

How to install Ruby on Rails 3.2 with SQLite3 on Debian/Ubuntu

This is the way I managed to install Ruby on rails 3.2 with SQLite3 on Debian/Ubuntu 12.04 (but it is valid also for previous versions of Ubuntu 11.04, 10.10, 10,04  etc) . I've chosen to install all the packages manually in a way that you can exactly know what you're installing and where.








     1.  INSTALL SOME LIBRARIES

  • Open the console copy and paste the following command:

 sudo apt-get install zlib1g zlib1g-dev build-essential sqlite3 libsqlite3-dev openssl libssl-dev libyaml-dev

     2.  DOWNLOAD AND INSTALL RUBY 1.9.3

  • Download the last version Ruby 1.9.3 in the "Compiling Ruby" section of the web page
  • Unzip the archive
  • Install running:
    •  ./configure
    • $   make
    • $   sudo make install
  • Check the successful installation running ruby -v: it should answer with "ruby 1.9.3p194..."

     3.  DOWNLOAD RUBY GEM: THE STANDARD RUBY PACKAGE MANAGER

  • Download ruby gem version 1.8.24 (rubygems-1.8.24.tgz)
  • Unzip the archive somewhere
  • Put the console in the unzipped folder
  • Install running:  $  sudo ruby setup.rb 
  • Check the successful installation running gem -v: it should reply "1.8.24"

     4.  INSTALL RAILS

  • Install Rails running on the console: $  sudo gem install rails 
  • (it takes a while, don't worry)
  • Check if everything's ok using the commands "rails -v" (you should get "Rails 3.2.8") or "gem list"

     5.  INSTALL SQLITE3 GEM

  • Install the sqlite3 gem running:  $  sudo gem install sqlite3

     6.  CREATE A NEW RAILS PROJECT

  • $  rails new myapp  
  • Wait a bit after the message   run  bundle install 
     7.  CREATE THE BLANK DATABASE

  • Put the console in myapp folder (cd myapp) and run:  $  rake db:create
          in order to create the databases  test.sqlite3 and development.sqlite3: (you can see them in db folder).
  • !!! If you receive some error jump to the session : 9. !! COMMON ISSUES THAT MIGHT OCCUR !!!

     8.  RUN YOUR RAILS APP

  • Put the console in myapp folder and run $  rails server
  • Open the browser
  • http://localhost:3000 
  • and you should see the Ruby on Rails: welcome page;-)



I suggest you to continue the ROR learning on the official documentation, in particular on the getting started page.

     9. !! COMMON ISSUES THAT MIGHT OCCUR !!
  • Running rake db:create or rake db:migrate you could get the error: uninitialized constant Rake::DSL. The solution is to put in the first line of your Rakefile: require 'rake/dsl_definition'
  • In the browser at localhost:3000 you could get the error: "no such file to load -- openssl". The solution is to go through the installation directory of ruby: ruby-1.9.2-p180/ext/openssl and run:
                  ruby extconf.rb
                  make
                  sudo make install
  • Running rake db:create the first time could generate this error:

rake aborted!
Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.

The error should be fixed adding in the Gemfile (in the root folder of your app) the lines:

gem 'execjs'
gem 'therubyracer'
  • and run sudo bundle
  • Put again the console in myapp folder and run:  $  rake db:create

I hope that everything went the right way, check the comments below, feel free to post comments or issues, please provide me a feedback ;-) AND DON'T FORGET TO +1 !

0 comments:

Post a Comment