Path: | faq.en.rd |
Last Update: | Fri Jan 17 08:06:51 MSK 2003 |
[((<Index|URL:index.en.html>)) |((<RD format|URL:faq.en.rd>))]
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>))]
It is available at the mod_ruby official site ((<URL:www.modruby.net/>)).
[((<Back to Index|mod_ruby FAQ>))]
mod_ruby is included in Debian GNU/Linux and FreeBSD.
RPM is provided by ((<Vine Linux|URL:www.vinelinux.org/index-en.html>)).
[((<Back to Index|mod_ruby FAQ>))]
((<URL: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:modruby-ctl@modruby.net>)).
[((<Back to Index|mod_ruby FAQ>))]
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.
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>))]
Not yet. Because I have no Windows machine (fortunately).
[((<Back to Index|mod_ruby FAQ>))]
Yes.
Please see ((<Install Guide|URL:install.en.html>)) to install mod_ruby with eRuby support.
[((<Back to Index|mod_ruby FAQ>))]
If ClearModuleList is in httpd.conf, Please write the following line after it.
AddModule mod_ruby.c
[((<Back to Index|mod_ruby FAQ>))]
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>))]
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>))]
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["filename"] filename.untaint file = open(filename)
Be careful not to make security holes!
[((<Back to Index|mod_ruby FAQ>))]
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>))]
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>))]
The Ruby interpreter may be in a panic because of bugs in other scripts. Please restart Apache.
[((<Back to Index|mod_ruby FAQ>))]
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:shugo@modruby.net>)).
[((<Back to Index|mod_ruby FAQ>))]
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>))]
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>))]
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>))]