安装Ruby on Rails技巧讲解

安装Ruby on Rails对于一个刚刚接触Ruby不久的新手来说是一个比较复杂的步骤。不过只要不断的积累经验,就会轻松的实现Ruby on Rails的安装。

51CTO推荐专题:Ruby on Rails开发教程

安装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”)。
对于这一步可能有异议。有人说第一步下载的已经包含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。如果报错,则执行:d:\ruby>gem clean然后d:\ruby>gem update然后继续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,当前最新版本为: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执行以下语句。

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 自动建立一些相关文件,如下:

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.

相关推荐