ruby on rails 在fedora18下的安裝javascript
天朝的網絡緣由,安裝不是很順暢,因此把過程記錄下備用css
前面下載rubygem什麼的都比較快,新建一個project的時候會出問題html
gem new my_project java
會在bundle_install處卡好久,而後提示說某某東西沒裝,讓裝一下。。node
大致上參考了兩篇文章:c++
【第一篇帖子,google快照裏找到的】
在Fedora系統安裝Ruby on Rails
這幾年一直在用AS3.0作開發,已經好久沒有接觸Linux了。博客上掛着Fedora的倒計時牌子,每次看到新版本倒計時一個接一個地陸續發佈,這個週末從新裝上了Fedora,學習一些其餘的Web開發知識。雖然說Ruby on Rails這幾年不是很流行了,並且近期Twitter改用java引發了不小的震動,有些人認爲RoR過期了,Ruby日薄西山了。我卻是以爲技術人員與其關注這些,不如去專一學習技術。git
RubyonRailsRubyonRailsgithub
安裝步驟web
Fedora更新很是快,我用的是目前最新的Fedora 18。雖然按照文檔和教程一步一步安裝的,但仍是遇到了不少問題。安裝的方法有不少種,這個和Ruby語言的特性也很類似 ;-);-) 。考慮到環境配置和開發工做,使用RVM安裝比較好,RVM能夠管理多個Ruby版本和RubyGem,在開發時能夠根據須要切換版本,配置環境也很方便。使用yum安裝ruby,管理比較麻煩,不適合開發工做。sql
安裝git和cURL
能夠考慮先更新全部包
Bash
yum update
安裝git
Bash
yum install git-core
安裝curl
Bash
yum install curl
安裝RVM
RVM,即Ruby Version Manager,能夠管理多個版本Ruby,RubyGem,Rails,對開發來講很是有用。
Bash
curl -L get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
安裝完畢後檢查RVM的軟件包依賴
Bash
rvm requirements
輸出信息以下:
TXT
Requirements for redhat/18./i386
NOTE: 'ruby' represents Matz's Ruby Interpreter (MRI) (1.8.X, 1.9.X)
This is the *original* / standard Ruby Language Interpreter
'ree' represents Ruby Enterprise Edition
'rbx' represents Rubinius
Additional Dependencies:
# For update-system:
# For rvm:
sudo yum install bash curl git patch
# For ruby:
sudo yum install gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison iconv-devel
# For jruby:
sudo yum install java
安裝其它組件
這些軟件是在運行時可能要用到的,根據須要安裝。
Javascript運行時
訪問ExecJS安裝可支持的JavaScript運行時,推薦安裝Node.js。
這裏有點麻煩,能夠先嚐試經過yum查找,名稱不必定是nodejs,若是有就安裝
Bash
yum search *nodejs*
yum install nodejs
若是沒有,就去找合適的RPM包,或者直接下載源代碼編譯安裝;
安裝node.js
Bash
cd node
sudo ./configure
sudo make
sudo make install
喝杯茶等待安裝完畢,檢查版本
TXT
[anthony@localhost ~]$ node -v
v0.9.8-pre
SQLite等組件
Bash
yum install libxslt-devel libxml2-devel sqlite-devel
安裝Ruby
安裝了RVM以後,全部Ruby相關的均可以用它來安裝配置了。
安裝Ruby
Bash
rvm install 1.9.3
若是報錯,須要添加參數
Bash
rvm install 1.9.3 --with-openssl-dir=$HOME/.rvm/
使用ruby 1.9.3做爲默認版本
Bash
rvm use 1.9.3 --default
檢查ruby版本
Bash
ruby -v
更新gems
Bash
gem update
安裝Rails
安裝rails
Bash
gem install rails
檢查rails版本
Bash
rails -v
Rails測試
安裝完了,接下來能夠用rails生成個helloWorld了。
Bash
mkdir rails_projects
cd rails_projects
rails new first_app
開始建立,喝杯茶……
TXT
create
create README.rdoc
create Rakefile
create config.ru
create .gitignore
create Gemfile
create app
create app/assets/images/rails.png
create app/assets/javascripts/application.js
create app/assets/stylesheets/application.css
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
create app/views/layouts/application.html.erb
create app/mailers/.gitkeep
create app/models/.gitkeep
create config
create config/routes.rb
create config/application.rb
create config/environment.rb
create config/environments
.
.
.
create vendor/plugins
create vendor/plugins/.gitkeep
run bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/..
Using rake (10.0.3)
Using i18n (0.6.1)
Using multi_json (1.5.0)
Using activesupport (3.2.11)
Using builder (3.0.4)
Using activemodel (3.2.11)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.4)
Using rails (3.2.11)
Using sass (3.2.5)
Using sass-rails (3.2.6)
Using sqlite3 (1.3.7)
Using uglifier (1.3.0)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
建立完畢,啓動服務器
Bash
cd first_app
rails server
好了,打開瀏覽器,登陸 http://localhost:3000看看 :-):-)
總結
萬事開頭難,第一次安裝時常常遇到各類問題:ruby安裝失敗,gem update報錯,rails生成報錯,啓動報錯等等。不過總算完成了,接下來的時間裏就要去邊作邊學了。
另外,我也開始嘗試使用Markdown來寫文檔了,這篇總結就是由Markdown格式轉換的。喝水不忘挖井人,最後緬懷一下Aaron Swartz。
Aaron SwartzAaron Swartz
參考資料
http://ruby.railstutorial.org/ruby-on-rails-tutorial-book
http://blog.sudobits.com/2012/05/02/how-to-install-ruby-on-rails-in-ubuntu-12-04-lts/
http://www.evansdiy.com/tips/the+way+to+install+nodejs
https://github.com/joyent/node#readme
【其餘文章】
http://stackoverflow.com/questions/9336596/rvm-installation-not-working-rvm-is-not-a-function
stackoverflow上關於rvm文件要生效後才能使用的討論
http://guides.ruby-china.org/getting_started.html
中文手冊,開始按照這個安裝步驟作,bundle install處發現了另外一個:http://ruby.taobao.org/ 淘寶鏡像。。。
json -v 1.8.0https://github.com/wpscanteam/wpscan/issues/92
至於ruby迷說的rails新建工程時的提速問題,能夠看http://rubyer.me/blog/941/
爲何要搞ruby on rails?由於看了這裏:http://blog.jobbole.com/15213/
關於web的幾個方面:框架+部署+版本控制+web語言,框架選擇了ruby on rails