ubuntu下通过源码编译安装ruby,安装时由于缺少一些库,所以源码安装时有些东西并没有安装上去如运行rails时出现如下错误:

Running RoR for the first time:
$  ruby script/server
___
/usr/local/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/initializer.rb:269:in `rescue in require_frameworks': no such file to load -- openssl (RuntimeError)
   from /usr/local/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/initializer.rb:266:in `require_frameworks'
   from /usr/local/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/initializer.rb:134:in `process'
   from /usr/local/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/initializer.rb:113:in `run'
   from /var/www/rubyweb/myweb/config/environment.rb:9:in `'
   from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require'
   from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `block in require'
   from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in `new_constants_in'
   from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require'
   from /usr/local/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/commands/server.rb:84:in `'
   from script/server:3:in `require'
   from script/server:3:in `

'

提示不能引导openssl,则肯定是源码安装ruby时确实库没有安装openssl,此时进行如下操作重新安装openssl:


$ sudo apt-get install openssl libssl-dev
$ sudo apt-get install ruby1.9.1-dev

/usr/src/ruby-1.9.1-p378为源码位置
$ cd /usr/src/ruby-1.9.1-p378/ext/openssl
$ sudo ruby extconf.rb
$ sudo make &&sudo make install

引用:http://linuxnuggetz.blogspot.com/2009/06/ruby-on-rail-on-ubuntu.html