Ubuntu 12.04,配置Ruby on Rails開發環境

來源:互聯網
上載者:User

標籤:des   style   blog   http   color   io   os   使用   java   

零、Ubuntu的安裝

官網下載,我裝的是12.04的x64版。

 

一、系統升級

更換ubuntu的源

1.備份更新源

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

2.修改更新源

$ sudo gedit /etc/apt/sources.list

使用以下網易源或搜狐源,直接替換檔案內容(教育網使用者請搜尋教育網神速專用源)

網易:

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

搜狐:

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.更新

$ sudo apt-get update

以上一步必須正常通過。

安裝curl:

$ sudo apt-get install curl

 

二、使用RVM安裝Ruby

RVM = Ruby Version Manager

輸入以下命令安裝RVM,並安裝最新stable版的ruby

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

安裝完成後,輸入以下命令檢查ruby安裝情況:

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

若已安裝RVM,則使用以下命令:

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

 

三、安裝JavaScript Runtime

$ sudo apt-get install nodejs

 

四、更新Gem Manager

更新gem:

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

更新gem源:

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

  

五、更新RVM全域gemset

查看全域gemset中的gem:

$ rvm gemset use global
$ gem list

更新至最新的stable gem:

$ gem update

安裝nokogiri:(慢)

$ gem install nokogiri

 

六、安裝Rails

建立一個rails4.1的gemset

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

安裝最新版本的rails

$ gem install rails$ rails -v

例如,你可以再建立一個rails3.2的gemset,安裝

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

在gemset間切換:

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

 

七、rails的hello world

切換至工作目錄

$ rails new demo
$ rails s

用瀏覽器開啟http://localhost:3000/,顯示如片說明安裝成功

 

本文參考http://railsapps.github.io/installrubyonrails-ubuntu.html,感謝作者對新人的無私協助

Ubuntu 12.04,配置Ruby on Rails開發環境

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.