Installing Mongrel 1.1.5 on Ruby 1.9.1

If you try to install mongrel on Mac OS X after installing Ruby 1.9.1, amd you getting an error like so:

i686-apple-darwin9-gcc -I. -I/gentoo/usr/include/ruby19-1.9.1/i686-darwin9 -I/gentoo/usr/include/ruby19-1.9.1/ruby/backward -I/gentoo/usr/include/ruby19-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -O2 -pipe -march=nocona -fno-strict-aliasing -O2 -g -Wall -Wno-parentheses -fno-common -pipe -fno-common -o http11.o -c http11.c
http11.c: In function ‘http_field’:
http11.c:77: error: ‘struct RString’ has no member named ‘ptr’
http11.c:77: error: ‘struct RString’ has no member named ‘len’
http11.c:77: warning: left-hand operand of comma expression has no effect
http11.c: In function ‘header_done’:
http11.c:172: error: ‘struct RString’ has no member named ‘ptr’
http11.c:174: error: ‘struct RString’ has no member named ‘ptr’
http11.c:176: error: ‘struct RString’ has no member named ‘ptr’
http11.c:177: error: ‘struct RString’ has no member named ‘len’
http11.c: In function ‘HttpParser_execute’:
http11.c:298: error: ‘struct RString’ has no member named ‘ptr’
http11.c:299: error: ‘struct RString’ has no member named ‘len’
make: *** [http11.o] Error 1

Here’s What you need to do in order to fix it

here’s the updated instructions:

1) cd /usr/local/lib/ruby/gems/1.9.1/gems/mongrel-1.1.5/ext/http11

2) sudo vi / mate on http11.c and:

replace line 77 with

for(ch = RSTRING_PTR(f), end = ch + RSTRING_LEN(f); ch < end; ch++) {

replace line 172 with
colon = strchr(RSTRING_PTR(temp), ':');

replace line 174 with

rb_hash_aset(req, global_server_name, rb_str_substr(temp, 0, colon - RSTRING_PTR(temp)));

replce line 176,177

rb_str_substr(temp, colon - RSTRING_PTR(temp)+1,
RSTRING_LEN(temp)));

replace lines 298 299

dptr = RSTRING_PTR(data);
dlen = RSTRING_LEN(data);

3) save the file, close the vi / textmate

4) sudo ruby extconf.rb && sudo make && sudo make install

5) cd ../../lib/mongrel
(or the full path “/usr/local/lib/ruby/gems/1.9.1/gems/mongrel-1.1.5/lib/mongrel”

6) mate / sudo vi handlers.rb

7) fix the case statements in

On lines 208-212, change instances of “: false” to “then false”

若还不行改完后运行下列语句:

ruby setup.rb
gem build mongrel.gemspec

gem install mongrel-1.1.5.gem

运行结果应为下列:

Building native extensions.  This could take a while...
Successfully installed mongrel-1.1.5
1 gem installed
Installing ri documentation for mongrel-1.1.5...
Updating class cache with 3467 classes...
Installing RDoc documentation for mongrel-1.1.5...

sudo gem install gem_plugin (else mongrel may hang)

done!

notes:
1) your current rails app config may stop mongrel from running
but i know for sure if you do a new rails app and run mongrel its working

2) sorry windows guys, try to find where the mongrel gem files will be stored for later review when you do gem install mongrel and get the error msg

转载自:http://rubynyc.wordpress.com/ruby-1-9-1/installing-mongrel-1-1-5-on-ruby-1-9-1/

具体修改内容见网址:http://github.com/gamache/mongrel-115-to-ruby-19/blob/master/mongrel-115-to-ruby-19.patch