Ubuntu 12.04, configure the Ruby on Rails Development Environment

Source: Internet
Author: User
Tags ruby on rails

Installation of ubuntu

Download from the official website. I installed x64 version 12.04.

 

I. System Upgrade

Change the Ubuntu Source

1. Back up the update source

$ sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup

2. Modify the update source

$ sudo gedit /etc/apt/sources.list

Use the following yiyuan or Sohu sources to directly replace the file content (for CERNET users, please search for the exclusive source of CERNET)

Netease:

deb http://mirrors.163.com/ubuntu/ precise main restricteddeb-src http://mirrors.163.com/ubuntu/ precise main restricteddeb http://mirrors.163.com/ubuntu/ precise-updates main restricteddeb-src http://mirrors.163.com/ubuntu/ precise-updates main restricteddeb http://mirrors.163.com/ubuntu/ precise universedeb-src http://mirrors.163.com/ubuntu/ precise universedeb http://mirrors.163.com/ubuntu/ precise-updates universedeb-src http://mirrors.163.com/ubuntu/ precise-updates universedeb http://mirrors.163.com/ubuntu/ precise multiversedeb-src http://mirrors.163.com/ubuntu/ precise multiversedeb http://mirrors.163.com/ubuntu/ precise-updates multiversedeb-src http://mirrors.163.com/ubuntu/ precise-updates multiversedeb http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiversedeb-src http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiversedeb http://mirrors.163.com/ubuntu/ precise-security main restricteddeb-src http://mirrors.163.com/ubuntu/ precise-security main restricteddeb http://mirrors.163.com/ubuntu/ precise-security universedeb-src http://mirrors.163.com/ubuntu/ precise-security universedeb http://mirrors.163.com/ubuntu/ precise-security multiversedeb-src http://mirrors.163.com/ubuntu/ precise-security multiversedeb http://extras.ubuntu.com/ubuntu precise maindeb-src http://extras.ubuntu.com/ubuntu precise main

Sohu:

deb http://mirrors.sohu.com/ubuntu/ precise main restricteddeb-src http://mirrors.sohu.com/ubuntu/ precise main restricteddeb http://mirrors.sohu.com/ubuntu/ precise-updates main restricteddeb-src http://mirrors.sohu.com/ubuntu/ precise-updates main restricteddeb http://mirrors.sohu.com/ubuntu/ precise universedeb-src http://mirrors.sohu.com/ubuntu/ precise universedeb http://mirrors.sohu.com/ubuntu/ precise-updates universedeb-src http://mirrors.sohu.com/ubuntu/ precise-updates universedeb http://mirrors.sohu.com/ubuntu/ precise multiversedeb-src http://mirrors.sohu.com/ubuntu/ precise multiversedeb http://mirrors.sohu.com/ubuntu/ precise-updates multiversedeb-src http://mirrors.sohu.com/ubuntu/ precise-updates multiversedeb http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiversedeb-src http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiversedeb http://mirrors.sohu.com/ubuntu/ precise-security main restricteddeb-src http://mirrors.sohu.com/ubuntu/ precise-security main restricteddeb http://mirrors.sohu.com/ubuntu/ precise-security universedeb-src http://mirrors.sohu.com/ubuntu/ precise-security universedeb http://mirrors.sohu.com/ubuntu/ precise-security multiversedeb-src http://mirrors.sohu.com/ubuntu/ precise-security multiversedeb http://extras.ubuntu.com/ubuntu precise maindeb-src http://extras.ubuntu.com/ubuntu precise main

3. Update

$ sudo apt-get update

The above steps must pass normally.

Install curl:

$ sudo apt-get install curl

 

Ii. Use rvm to install Ruby

Rvm = Ruby version Manager

Run the following command to install rvm and install Ruby of the latest stable version.

$ \curl -L https://get.rvm.io | bash -s stable --ruby

After the installation is complete, enter the following command to check the ruby installation:

$ ruby -vruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]

If you have installed rvm, run the following command:

$ rvm get stable --autolibs=enable$ rvm install ruby$ rvm --default use ruby-2.1.2

 

3. Install JavaScript Runtime

$ sudo apt-get install nodejs

 

4. Update gem Manager

Update GEM:

$ gem update --system$ gem -v2.4.1

Update the gem Source:

$ gem source -l$ gem source -r https://rubygems.org/$ gem source -a http://ruby.taobao.org/

5. Update the rvm global gemset

View the gem in the global gemset:

$ rvm gemset use global
$ gem list

Update stable gem to the latest version:

$ gem update

Install nokogiri: (slow)

$ gem install nokogiri

 

6. Install rails

Create a gemset for rails4.1

$ rvm use ruby-2.1.2@rails4.1 --create

Install the latest version of rails

$ gem install rails$ rails -v

For example, you can create another gemset for rails3.2 to install

$ rvm use ruby-2.1.2@rails3.2 --create$ gem install rails --version=3.2.19$ rails -v

Switch between gemset:

$ rvm use ruby-2.1.2@rails4.1$ rvm use ruby-2.1.2@rails3.2

 

7. rails's hello World

Switch to working directory

$ rails new demo
$ rails s

Open http: // localhost: 3000/in the browser, and the installation is successful if it is displayed as an example.

 

For more information, see http://railsapps.github.io/installrubyonrails-ubuntu.html.

Ubuntu 12.04, configure the Ruby on Rails Development Environment

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.