1、install ruby
apt-get install irb libdbm-ruby1.8 libgdbm-ruby1.8 libmysql-ruby1.8 libmysqlclient14 libopenssl-ruby1.8 libruby1.8-dbg mysql-common ri ri1.8 ruby1.8-dev
2、install rubygem
#http://rubyforge.org/frs/?group_id=126&release_id=20667
wget http://rubyforge.org/frs/download.php/34638/rubygems-1.1.0.tgz
tar zxfv rubygems-1.1.0.tgz
cd rubygems-1.1.0
sudo ruby setup.rb
提示:
RubyGems installed the following executables:
/usr/bin/gem1.8
运行:gem1.8 update –system
3、install Rails and dependencies
sudo gem1.8 install rails –include-dependencies
4、intall Mongrel
sudo apt-get install build-essential
sudo gem1.8 install mongrel –include-dependencies
5、测试
rails 版本:
rails -v
Rails 2.0.2
建立测试应用:
rails cookbook
cd cookbook
./script/server
打开http://localhost:3000/即可看到首页
注:
1、我在安装时,运行sudo ruby setup.rb时出现如下错误:
./lib/rubygems/custom_require.rb:27:in `gem_original_require’: no such file to load — rdoc/rdoc (LoadError)
from ./lib/rubygems/custom_require.rb:27:in `require’
from setup.rb:48
解决方法如下:sudo apt-get install -f rdoc
2、在运行./script/server时出现如下错误:
=> Booting WEBrick…
/usr/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/initializer.rb:159:in `require_frameworks’: no such file to load — openssl (RuntimeError)
from /usr/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/initializer.rb:88:in `process’
from /usr/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/initializer.rb:49:in `send’
from /usr/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/initializer.rb:49:in `run’
from /home/kokko/cookbook/config/environment.rb:13
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require’
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require’
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require’
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in’
… 7 levels…
from /usr/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require’
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require’
from ./script/server:3
出现此错误的原因是没有安装了libopenssl-ruby 的缘故
kokko@kokko-laptop:~/cookbook$ sudo apt-cache search libopenssl-ruby
libopenssl-ruby – OpenSSL interface for Ruby
libopenssl-ruby1.9 – OpenSSL interface for Ruby 1.9
ruby1.8 – Interpreter of object-oriented scripting language Ruby 1.8
libopenssl-ruby1.8 – OpenSSL interface for Ruby 1.8
这里使用的是ruby1.8,运行 sudo apt-get install libopenssl-ruby1.8 即可。