安裝Ruby on Rails技巧講解
安裝Ruby on Rails對于一個剛剛接觸Ruby不久的新手來說是一個比較復(fù)雜的步驟。不過只要不斷的積累經(jīng)驗,就會輕松的實現(xiàn)Ruby on Rails的安裝。#t#
51CTO推薦專題:Ruby on Rails開發(fā)教程
安裝Ruby on Rails***步,http://rubyforge.org/frs/download.php/33195/mongrel-1.1.4-x86-mswin32-60.gem
,下載后的文件名為:ruby186-26.exe。安裝,我的目錄是D:/ruby.安裝好后,cmd下 d:\ruby>ruby -v顯示安裝的版本信息。成功。
安裝Ruby on Rails第二步:http://rubyforge.org/frs/download.php/33195/mongrel-1.1.4-x86-mswin32-60.gem
下載RubyGems.(解壓縮后運行“ruby setup.rb”)。
對于這一步可能有異議。有人說***步下載的已經(jīng)包含RubyGems,第二步是不需要的。本人實踐是需要第二步的,不代表其他人。
安裝Ruby on Rails第三步:不建議直接安裝,建議先下載到本地,放到ruby文件下然后安裝。下載rails,本文下載的是rails2.0.2版本(下載后的文件名是:rails-2.0.2.zip),下載地址為:http://rubyforge.org/frs/download.php/33195/mongrel-1.1.4-x86-mswin32-60.gem
。放到ruby文件下后需要將壓縮文件改名為rails.zip.
安裝Ruby on Rails第四步:d:\ruby>gem install rails。如果報錯,則執(zhí)行:d:\ruby>gem clean然后d:\ruby>gem update然后繼續(xù)d:\ruby>gem install rails信息如下:
D:\ruby>gem install rails
Successfully installed rake-0.8.7
Successfully installed activesupport-2.3.5
Successfully installed activerecord-2.3.5
Successfully installed rack-1.0.1
Successfully installed actionpack-2.3.5
Successfully installed actionmailer-2.3.5
Successfully installed activeresource-2.3.5
Successfully installed rails-2.3.5
8 gems installed
Installing ri documentation for rake-0.8.7...
Installing ri documentation for activesupport-2.3.5...
Installing ri documentation for activerecord-2.3.5...
Installing ri documentation for rack-1.0.1...
Installing ri documentation for actionpack-2.3.5...
Installing ri documentation for actionmailer-2.3.5...
Installing ri documentation for activeresource-2.3.5...
Installing ri documentation for rails-2.3.5...
Installing RDoc documentation for rake-0.8.7...
Installing RDoc documentation for activesupport-2.3.5...
Installing RDoc documentation for activerecord-2.3.5...
Installing RDoc documentation for rack-1.0.1...
Installing RDoc documentation for actionpack-2.3.5...
Installing RDoc documentation for actionmailer-2.3.5...
Installing RDoc documentation for activeresource-2.3.5...
Installing RDoc documentation for rails-2.3.5...
安裝Ruby on Rails第五步:下載Mongrel,當(dāng)前***版本為:1.1.4,下載地址為:http://rubyforge.org/frs/download.php/33195/mongrel-1.1.4-x86-mswin32-60.gem
安裝mogrel還需要額外地下載gem plugin、daemons、fastthread、cgi_multipart_eof_fix,下載地址為
gen_plugin:http://rubyforge.org/frs/download.php/27044/gem_plugin-0.2.3.gem
daemons:http://rubyforge.org/frs/download.php/34222/daemons-1.0.10.gem
fastthread:http://rubyforge.org/frs/download.php/29508/fastthread-1.0.1-i386-mswin32.gem
cgi_multipart_eof_fix:http://rubyforge.org/frs/download.php/33195/mongrel-1.1.4-x86-mswin32-60.gem
安裝Ruby on Rails第六步:安裝mongrel。將第五步下載的文件放到ruby文件夾下,cmd執(zhí)行以下語句。
gem install gem_plugin-0.2.3.gem
gem install daemons-1.0.10.gem
gem install fastthread-1.0.1-i386-mswin32.gem
gem install cgi_multipart_eof_fix-2.5.0.gem
gem install mongrel-1.1.4-x86-mswin32-60.gem
安裝Ruby on Rails第七步:在D盤建立rubyPro,rubyPro下建立hello文件夾。
安裝Ruby on Rails第八步:D:\rubyPro\hello>rails hello 自動建立一些相關(guān)文件,如下:
create
create app/controllers
create app/helpers
create app/models
create app/views/layouts
create config/environments
create config/initializers
create config/locales
這里太多,只列出幾個。
安裝Ruby on Rails第九步:啟動mongrel.D:\rubyPro\hello\hello>mongrel_rails start -d注意路徑,如果路徑錯了的話,會報如下類似的錯誤:
!!! Path to log file not valid: log/mongrel.log
mongrel::start reported an error. Use mongrel_rails mongrel::start -h to get help.
安裝Ruby on Rails第十步:好了,訪問下自己電腦的port3000。顯示rails的界面。到此OK。
PS:發(fā)現(xiàn)mongre跟weblogic的命令很多相似。比如,想停止的時候:ctrl+c,然后Y,然后回車。呵呵。