最近readmine速度越来越慢。网上查了一下,把其自带的服务器webrick 换成为mongrel,可以解决这个问题,具体操作方法如下,方法:
gem install mongrel
如果提示类似“
http11.c: In function ‘header_done’: http11.c:172:13: error: ‘struct RString’ has no member named ‘ptr’ http11.c:172:13: error: ‘struct RString’ has no member named ‘ptr’ http11.c:172:13: error: ‘struct RString’ has no member named ‘ptr’ http11.c:174:89: error: ‘struct RString’ has no member named ‘ptr’ http11.c:176:52: error: ‘struct RString’ has no member named ‘ptr’ http11.c:177:26: error: ‘struct RString’ has no member named ‘len’ http11.c: In function ‘HttpParser_execute’: http11.c:298:23: error: ‘struct RString’ has no member named ‘ptr’ http11.c:299:23: error: ‘struct RString’ has no member named ‘len’ http11.c:307:5: warning: format not a string literal and no format arguments [-Wformat-security] make: *** [http11.o] Error 1之类的错误的话,需要先执行一下
sudo gem install mongrel --pre安装mongrel替代webrick,遇到如下问题(ruby版本1.9.2 rails版本3.1.3)
ERROR: Error installing mongrel:
ERROR: Failed to build gem native extension.
原因在于Mongrel 1.1.5与Ruby 1.9.x 不兼容。可以通过安装另个版本
gem install mongrel --pre
或者
gem install mongrel -v 1.2.0.pre2 --pre --sourcehttp://ruby.taobao.org
成功安装
安装完后运行:[root@yyzctest redmine-2.1.2]# ruby script/rails server mongrel -e production -d -p9042
/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/handler/mongrel.rb:1:in `require': cannot load such file -- mongrel (LoadError)
from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/handler/mongrel.rb:1:in `'
from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/handler.rb:20:in `const_get'
from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/handler.rb:20:in `block in get'
from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/handler.rb:20:in `each'
from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/handler.rb:20:in `inject'
from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/handler.rb:20:in `get'
from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:269:in `server'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands/server.rb:59:in `start'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:55:in `block in '
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:50:in `tap'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:50:in `'
from script/rails:6:in `require'
from script/rails:6:in `'
[root@yyzctest redmine-2.1.2]# /mongrel.rb:1:in `require': cannot load such file -- mongrel (LoadError)
还是一样报错.需要做如下操作:
redmine 文件夹下找到gemfile 文件,打开加入下面一句
gem 'mongrel','~> 1.2.0.pre2'
2、运行[root@yyzctest redmine-2.1.2]# ruby script/rails server mongrel -e production -d -p9042 => Booting Mongrel => Rails 3.2.8 application starting in production on http://0.0.0.0:9042 /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `block in require': iconv will be deprecated in the future, use String#encode instead. [root@yyzctest redmine-2.1.2]#
速度比以前快多了