File: faq.en.rd

package info (click to toggle)
mod-ruby 1.2.6-2
  • links: PTS
  • area: main
  • in suites: lenny, squeeze, wheezy
  • size: 704 kB
  • ctags: 978
  • sloc: ansic: 6,779; ruby: 1,954; makefile: 77; sh: 16
file content (256 lines) | stat: -rw-r--r-- 6,515 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
=begin

= mod_ruby FAQ

[((<Index|URL:index.en.html>))
|((<RD format|URL:faq.en.rd>))]

* ((<What is mod_ruby?>))
* ((<Where is it available?>))
* ((<Are there binary packages?>))
* ((<Is there a mailing list?>))
* ((<Is it secure?>))
* ((<Is it effective for heavy scripts?>))
* ((<Does It work on Windows?>))
* ((<Can I use eRuby on mod_ruby?>))
* ((<LoadModule does not work.>))
* ((<Why is "Content-Type" displayed on my browser?>))
* ((<Why are changes to my library not reflected in the server?>))
* ((<SecurityError is raised.>))
* ((<Location header does not work.>))
* ((<CGI::Session does not work.>))
* ((<I don't know why error has occurred!>))
* ((<Apache dies.>))
* ((<(({apachectl restart})) causes memory leaks.>))
* ((<Can't find libruby.so or liberuby.so.>))
* ((<Can't override existing classes>))

== What is mod_ruby?

mod_ruby embeds the Ruby interpreter into the Apache web server,
allowing Ruby CGI scripts to be executed natively. These scripts will
start up much faster than without mod_ruby.

[((<Back to Index|mod_ruby FAQ>))]

== Where is it available?

It is available at the mod_ruby official site ((<URL:http://www.modruby.net/>)).

[((<Back to Index|mod_ruby FAQ>))]

== Are there binary packages?

mod_ruby is included in Debian GNU/Linux and FreeBSD.

RPM is provided by
((<Vine Linux|URL:http://www.vinelinux.org/index-en.html>)).

[((<Back to Index|mod_ruby FAQ>))]

== Is there a mailing list?

((<URL:mailto:modruby@modruby.net>)) is set up for a purpose
to talk about mod_ruby (and eruby).

To subscribe this list, please send the following phrase

  subscribe Your-First-Name Your-Last-Name 

in the mail body (not subject) to the address
((<URL:mailto:modruby-ctl@modruby.net>)).

[((<Back to Index|mod_ruby FAQ>))]

== Is it secure?

Yes, and No.

The default value of $SAFE is 1 on mod_ruby, so it's secure for careless
programmers. For example eval(cgi["foo"][0]) causes SecurityError.

But on the other side, different scripts run using the same Ruby interpreter,
so a malicious script can change the behavior of the other scripts.

== Is it effective for heavy scripts?

Yes.

Someone may think fork() has little cost, relatively, for heavy scripts,
so mod_ruby is not an effective way to start such scripts.
But in fact it is effective, because decreasing the number of processes
helps the server especially when many clients make requests simultaneously.

[((<Back to Index|mod_ruby FAQ>))]

== Does It work on Windows?

Not yet.
Because I have no Windows machine (fortunately).

[((<Back to Index|mod_ruby FAQ>))]

== Can I use eRuby on mod_ruby?

Yes.

Please see ((<Install Guide|URL:install.en.html>))
to install mod_ruby with eRuby support.

[((<Back to Index|mod_ruby FAQ>))]

== LoadModule does not work.

If ClearModuleList is in httpd.conf, Please write
the following line after it.

  AddModule mod_ruby.c

[((<Back to Index|mod_ruby FAQ>))]

== Why is "Content-Type" displayed on my browser?

This script does not work correctly on mod_ruby.

  print "Content-Type: text/plain\r\n\r\n"
  print "hello world"

Because mod_ruby is compatible with NPH-CGI, so does not output
the HTTP status-line.
You have to output it yourself.

  print "HTTP/1.1 200 OK\r\n"
  print "Content-Type: text/plain\r\n\r\n"
  print "hello world"

Or you can use cgi.rb.

  require "cgi"
  
  cgi = CGI.new
  print cgi.header("type"=>"text/plain")
  print "hello world"

This script is better than the previous one.

[((<Back to Index|mod_ruby FAQ>))]

== Why are changes to my library not reflected in the server?

mod_ruby scripts share the Ruby interpreter.
So a library is loaded once, (({require})) does not load the library later.

Please restart Apache like this:

  # apachectl restart

Or use (({load})) instead of (({require})) for debugging.

[((<Back to Index|mod_ruby FAQ>))]

== SecurityError is raised.

On mod_ruby the default value of (({$SAFE})) is (({1})),
so dangerous operations with tainted string cause a SecurityError.

If it is certain that the operation is secure, use (({untaint})).

  query = CGI.new
  filename = query.params["filename"][0].dup
  filename.untaint
  file = open(filename)

Be careful not to make security holes!

[((<Back to Index|mod_ruby FAQ>))]

== Location header does not work.

Please specify the status line like this:

  r = Apache.request
  r.status_line = "302 Found"
  r.headers_out["Location"] = "http://www.modruby.net/"
  r.content_type = "text/html; charset=iso-8859-1"
  r.send_http_header
  print "<html><body><h1>302 Found</h1></body></html>"

Or specify the exit status like this.

  r = Apache.request
  r.headers_out["Location"] = "http://www.modruby.net/"
  exit Apache::REDIRECT

[((<Back to Index|mod_ruby FAQ>))]

== CGI::Session does not work.

On mod_ruby, CGI::Session is not closed automatically, so you should
close it explicitly.

  session = CGI::Session.new(...)
  begin
    ...
  ensure
    session.close
  end

This problem is not CGI::Session specific. You should close files etc too.

[((<Back to Index|mod_ruby FAQ>))]

== I don't know why error has occurred!

The Ruby interpreter may be in a panic because of bugs in other scripts.
Please restart Apache.

[((<Back to Index|mod_ruby FAQ>))]

== Apache dies.

Ruby built by egcs-1.1.2 may cause Segmentation Fault.
Please try the latest Ruby (1.6.2 or later).

Otherwise please send a bug report to the author
((<Shugo Maeda|URL:mailto:shugo@modruby.net>)).

[((<Back to Index|mod_ruby FAQ>))]

== (({apachectl restart})) causes memory leaks.

Currently, Ruby API does not provide a way to free memory that has
been allocated by the interpreter. So mod_ruby can't free memory on
(({apachectl graceful})).

Please stop and start Apache for the time being.

  # apachectl restart

[((<Back to Index|mod_ruby FAQ>))]

== Can't find libruby.so or liberuby.so.

libruby.so may not be in the runtime library search path.

On many Linux distributions, /usr/local/lib is not included in the runtime
library search path.
If you are installing mod_ruby under /usr/local, Please add the fllowing line
to /etc/ld.so.conf, and run ldconfig.

  /usr/local/lib

[((<Back to Index|mod_ruby FAQ>))]

== Can't override existing classes

You can't override classes in your mod_ruby scripts directly.
(Instead, a new class will be defined.)
Because mod_ruby scripts are loaded by Kernel#load(filename,
true).

If you have to override existing classes, please do it in a
library, then require it from your mod_ruby scripts.

[((<Back to Index|mod_ruby FAQ>))]

=end