Using ubuntu is a bit complicated and requires patience in terms of installed software / application, but there is excess of gladness if we successfully installed. A little review about How to install Ruby on Rails 3.1 with SQLite3 on Ubuntu 11, thanks for Cicolink Blog.
This manual to install Ruby on Rails 3.1 with SQLite3 on Ubuntu 11:10 (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 THE NEEDED LIBRARIES
Open the Synaptic Package Manager: Ubuntu 11.10 has the Unity desktop manager, you can find the Package Manager into the menu, searching for "software". If synaptic is not installed you can search it into the Ubuntu Software Center. This is the software manager (in my language):
- search and install the following packages (if they're not already installed) zlib1g, zlib1g-dev, build-essential, sqlite3, libsqlite3-dev, openssl, libssl-dev
- Download the last version Ruby 1.9.2 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.2p290..."
- Download ruby gem version 1.8.10 (rubygems-1.8.10.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.10"
- 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.1.0") or "gem list"
- Install the sqlite3 gem running: $ sudo gem install sqlite3
- $ rails new myapp
- Wait a bit after the message run bundle install
- Put the console in myapp folder (cd myapp) and run: $ rake db:create
- !!! If you receive some error jump to the session : 9. !! COMMON ISSUES THAT MIGHT OCCUR !!!
- 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;-)
- 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:
- 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