Pages

Friday, 23 August 2013

debian下,手工安装ruby on rails


希望这个ror能够像我当初发现jquery能够大幅提高javascript和ajax开发效率那样令我惊喜.

安装开始:
1、按这里http://www.rubyonrails.org/down的步骤,先安装ruby:sudo apt-get install ruby ri rdoc
(包括解释器,即时执行工具irb,本地文档)

2、下载rubygems,http://rubyforge.org/frs/?group_id=126,http://rubyforge.org/frs/download.php/28174/rubygems-0.9.5.tgz ,解压,然后进入到解压缩后的文件夹执行:
ruby setup.rb

但不知为何总是出现:

As of RubyGems 0.8.0, library stubs are no longer needed.
Searching $LOAD_PATH for stubs to optionally delete (may take a while)…
…done.
No library stubs found.

这里人家都说好了新版的不需要library stubs,可是我却以为这是安装失败,看来对linux还是都没有一点信心啊。。搜索 “No library stubs found”找到http://forum.ubuntu.org.cn/viewtopic.php?t=23851 ,看到有人跟我一样,但也如他说的: “最下面出现No library stubs found. 不知为何….没有理会继续….最终还是成功了….”

3、安装rails:gem install rails
Bulk updating Gem source index for: http://gems.rubyforge.org
这步等了很久才安装好,但最后又提示:
ERROR: While executing gem … (Gem::Exception)
SSL is not installed on this system

不理它,但运行rails找不到命令!提示:
The program ‘rails’ is currently not installed. You can install it by typing:
apt-get install rails
Make sure you have the ‘universe’ component enabled

于是google:SSL is not installed on this system
看到:http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/a420e3eced6675f2/1c55a165a9319778?lnk=raot
是因为没有安装libopenssl-ruby:
于是安装:apt-get install libopenssl-ruby

然后重新:gem install rails
 又出现:
ERROR: While executing gem … (Gem::RemoteFetcher::FetchError)
OpenURI::HTTPError: 404 Not Found reading http://gems.rubyforge.org/gems/activerecord-1.15.6.gem

似乎是网络不行了,再试: gem install rails
提示:
INFO: `gem install -y` is now default and will be removed
INFO: use –ignore-dependencies to install only the gems you list
Successfully installed activerecord-1.15.6
Successfully installed actionpack-1.13.6
Successfully installed actionmailer-1.3.6
Successfully installed actionwebservice-1.2.6
Successfully installed rails-1.2.6
5 gems installed
Installing ri documentation for activerecord-1.15.6…
Installing ri documentation for actionpack-1.13.6…
Installing ri documentation for actionmailer-1.3.6…
Installing ri documentation for actionwebservice-1.2.6…
Installing RDoc documentation for activerecord-1.15.6…
Installing RDoc documentation for actionpack-1.13.6…
Installing RDoc documentation for actionmailer-1.3.6…
Installing RDoc documentation for actionwebservice-1.2.6…
最终安装好了。这时输入rails就可以显示出帮助
rails -v 为1.2.6

4、下载安装一个好用的ruby on rails ide:radrails
因为radrails已经和Aptana集成,而Aptana有60多M,而radrails只有40几M,想了想我还是下载了radrails,简洁些。不需要ftp等无用的功能,在sourceforge上下载:http://nchc.dl.sourceforge.net/sourceforge/radrails/radrails-0.7.2-linux-gtk.tar.gz
下载后解压即可直接使用,与windows上一样方便(但要有java支持,需先安装jdk,我在安装lumaqq时就已经安装过了)

5、建立第一个ror项目:
在radrails中新建一个ruby on rails项目(Files – New – Rails – Rails Project),启动server(即按那个绿色的播放按钮),然后launch browser或者在Firefox中输入:http://localhost:3000/ 即可查看用ror建立的网页了。
一切OK了,接下来的一段时间,就要开始ror之旅。。。

参考:
官方:http://www.rubyonrails.org/down
Ubuntu中文:HOWTO:Ruby on Rails:http://forum.ubuntu.org.cn/viewtopic.php?t=23851
利用Radrails开发Ruby on Rails程序入门指南-http://www.blogjava.net/maninred/archive/2007/08/31/141691.html
ubuntu上安装ruby on rails:http://steve-gu.javaeye.com/blog/56299
http://www.blogjava.net/wuxufeng8080/category/22308.html
ubuntu中文的wiki(看来以后得改改搜索的习惯了,对于安装这样普遍性的问题,可以先看看官方的wiki,而不是打开google乱搜)
[IBM,推荐]使用 RadRails 和 Eclipse 可以轻松进行 Ruby on Rails 开发:http://www-128.ibm.com/developerworks/cn/opensource/os-ecl-radrails/index.html?S_TACT=105AGX52&S_CMP=techcsdn#main