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 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591
|
<html><title>Programming Ruby: The Pragmatic Programmer's Guide</title><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><STYLE TYPE="text/css"><!--
BODY { margin-left: 1in;
width: 6in;
font-family: helvetica, arial, sans-serif;
}
H1 { color: #000080;
font-family: helvetica, arial, sans-serif;
font-size: 22pt;
margin-left: 0in
}
H2 { color: #000080; font: bold x-large helvetica, sans-serif;
margin-left: 0in }
H3 { color: #000080; font: bold large helvetica, sans-serif; }
H4 { color: #000080; font: italic large helvetica, sans-serif; }
.ruby { background: #fff0f0 }
.header { color: white }
.subheader { color: #ffdddd }
.sidebar { width: 6in }
span.sans { font-family: helvetica, arial, sans-serif }
-->
</STYLE><table bgcolor="#a03030" cellpadding="3" border="0" cellspacing="0"><tr><td colspan="3"><table bgcolor="#902020" cellpadding="20"><tr><td><h1 class="header">Programming Ruby</h1><h3 class="subheader">The Pragmatic Programmer's Guide</h3></td></tr></table></td></tr><tr><td width="33%" align="left"><a class="subheader" href="rubyworld.html">Previous <</a></td><td width="33%" align="center" valign="middle"><a class="subheader" href="index.html">Contents ^</a><br></td><td width="33%" align="right"><a class="subheader" href="ext_tk.html">Next ></a><br></td></tr></table></head><body bgcolor="white">
<!--
Copyright (c) 2001 by Addison Wesley Longman. This
material may be distributed only subject to the terms and
conditions set forth in the Open Publication License, v1.0 or
later (the latest version is presently available at
http://www.opencontent.org/openpub/).
-->
<h1>Ruby and the Web</h1><hr><br>
<P></P>
Ruby is no stranger to the Internet. Not only can you write your own
SMTP server, FTP daemon, or Web server in Ruby, but you can also use
Ruby for more usual tasks such as CGI programming or as a
replacement for PHP.
<h2>Writing CGI Scripts</h2>
<P></P>
You can use Ruby to write CGI scripts quite easily. To have a Ruby
script generate HTML output, all you need is
<P></P>
<table bgcolor="#fff0f0" cellspacing="0" border="0" cellpadding="3" width="400"><tr><td><pre>
#!/usr/bin/env ruby
print "HTTP/1.0 200 OK\r\n"
print "Content-type: text/html\r\n\r\n"
print "<html><body>Hello World!</body></html>\r\n"
</pre></td></tr></table>
<P></P>
You <em>could</em> use Ruby's regular expression features to parse
incoming query strings, look up environment variables, check tags,
substitute text into templates, escape special characters, format up
the HTML, and print it all out.
<P></P>
Or, you could use class <code>CGI</code>.
<h3>Using cgi.rb</h3>
<P></P>
Class <code>CGI</code> provides support for writing CGI scripts. With it, you
can manipulate forms, cookies, and the environment, maintain stateful
sessions, and so on. It's documented in full in the reference section
beginning on page 501, but we'll take a quick look at its
capabilities here.
<h3>Quoting</h3>
<P></P>
When dealing with URLs and HTML code, you must be careful to quote
certain characters. For instance, a slash character (``/'') has
special meaning in a URL, so it must be ``escaped'' if it's not part
of the path name. That is, any ``/'' in the query portion of the URL
will be translated to the string ``<code>%2F</code>'' and must be translated back
to a ``/'' for you to use it. Space and ampersand are also special
characters. To handle this, <code>CGI</code> provides the routines
<code>CGI#escape</code> and <code>CGI#unescape</code>:
<P></P>
<table bgcolor="#fff0f0" cellspacing="0" border="0" cellpadding="3" width="400"><tr><td><pre>
require 'cgi'
puts CGI.escape( "Nicholas Payton/Trumpet & Flugel Horn" )
</pre></td></tr></table>
<em>produces:</em>
<table bgcolor="#fff0f0" cellspacing="0" border="0" cellpadding="3" width="400"><tr><td><pre>
Nicholas+Payton%2FTrumpet+%26+Flugel+Horn
</pre></td></tr></table>
<P></P>
Similarly, you may want to escape HTML special characters:
<P></P>
<table bgcolor="#fff0f0" cellspacing="0" border="0" cellpadding="3" width="400"><tr><td><pre>
require 'cgi'
puts CGI.escapeHTML( '<a href="/mp3">Click Here</a>' )
</pre></td></tr></table>
<em>produces:</em>
<table bgcolor="#fff0f0" cellspacing="0" border="0" cellpadding="3" width="400"><tr><td><pre>
&lt;a href=&quot;/mp3&quot;&gt;Click Here&lt;/a&gt;
</pre></td></tr></table>
<P></P>
To get really fancy, you can decide to escape only certain elements
within a string:
<P></P>
<table bgcolor="#fff0f0" cellspacing="0" border="0" cellpadding="3" width="400"><tr><td><pre>
require 'cgi'
puts CGI.escapeElement('<hr><a href="/mp3">Click Here</a><br>','A')
</pre></td></tr></table>
<em>produces:</em>
<table bgcolor="#fff0f0" cellspacing="0" border="0" cellpadding="3" width="400"><tr><td><pre>
<hr>&lt;a href=&quot;/mp3&quot;&gt;Click Here&lt;/a&gt;<br>
</pre></td></tr></table>
<P></P>
Here only the ``<code>A</code>'' tag is escaped; other tags are left alone.
Each of these methods has an ``<code>un</code>-'' version to restore the original
string.
<h3>Forms</h3>
<P></P>
Using class <code>CGI</code> gives you access to HTML query parameters in two
ways.
Suppose we are given a URL of
<code>/cgi-bin/lookup?player=Miles%20Davis&year=1958</code>. You can access
the parameters ``<code>player</code>'' and ``<code>year</code>'' using <code>CGI#[]</code> directly:
<P></P>
<table bgcolor="#fff0f0" cellspacing="0" border="0" cellpadding="3" width="500">
<tr>
<td colspan="3" valign="top"><code>require 'cgi'</code></td>
</tr>
<tr>
<td colspan="3" valign="top"><code>cgi = CGI.new</code></td>
</tr>
<tr>
<td valign="top"><code>cgi['player']</code></td>
<td valign="top"></td>
<td valign="top"><code>["Miles Davis"]</code></td>
</tr>
<tr>
<td valign="top"><code>cgi['year']</code></td>
<td valign="top"></td>
<td valign="top"><code>["1958"]</code></td>
</tr>
</table>
<P></P>
<P></P>
Or, you can retrieve all parameters as a <code>Hash</code>:
<P></P>
<table bgcolor="#fff0f0" cellspacing="0" border="0" cellpadding="3" width="500">
<tr>
<td colspan="3" valign="top"><code>require 'cgi'</code></td>
</tr>
<tr>
<td colspan="3" valign="top"><code>cgi = CGI.new</code></td>
</tr>
<tr>
<td colspan="3" valign="top"><code>h = cgi.params</code></td>
</tr>
<tr>
<td valign="top"><code>h['player']</code></td>
<td valign="top"></td>
<td valign="top"><code>["Miles Davis"]</code></td>
</tr>
</table>
<P></P>
<h3>Creating Forms and HTML</h3>
<P></P>
<code>CGI</code> contains a huge number of methods used to create HTML---one
method per tag. In order to enable these methods, you must create a
<code>CGI</code> object by calling <code>CGI#new</code>, passing in the required level
of HTML. For these examples, we'll use ``<code>html3</code>''.
<P></P>
To make tag nesting easier, these methods take their content as code
blocks. The code blocks should return a <code>String</code>, which will be
used as the content for the tag. For this example, we've added some
gratuitous newlines to make the output fit on the page.
<P></P>
<table bgcolor="#fff0f0" cellspacing="0" border="0" cellpadding="3" width="400"><tr><td><pre>
require "cgi"
cgi = CGI.new("html3") # add HTML generation methods
cgi.out{
cgi.html{
cgi.head{ "\n"+cgi.title{"This Is a Test"} } +
cgi.body{ "\n"+
cgi.form{"\n"+
cgi.hr +
cgi.h1 { "A Form: " } + "\n"+
cgi.textarea("get_text") +"\n"+
cgi.br +
cgi.submit
}
}
}
}
</pre></td></tr></table>
<em>produces:</em>
<table bgcolor="#fff0f0" cellspacing="0" border="0" cellpadding="3" width="400"><tr><td><pre>
Content-Type: text/html
Content-Length: 302
<P></P>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><HTML><HEAD>
<TITLE>This Is a Test</TITLE></HEAD><BODY>
<FORM METHOD="post" ENCTYPE="application/x-www-form-urlencoded">
<HR><H1>A Form: </H1>
<TEXTAREA COLS="70" NAME="get_text" ROWS="10"></TEXTAREA>
<BR><INPUT TYPE="submit"></FORM></BODY></HTML>
</pre></td></tr></table>
<P></P>
This code will produce an HTML form titled ``This Is a Test,''
followed by a horizontal rule, a level-one header, a test input area,
and finally a submit button. When the submit comes back, you'll have
a CGI parameter named ``<code>get_text</code>'' containing the text the
user entered.
<h3>Cookies</h3>
<P></P>
You can store all kinds of interesting stuff on an unsuspecting
surfer's machine using <em>cookies</em>.
You can create a named cookie
object and store a number of values in it. To send it down to the
browser, set a ``cookie'' header in the call to <code>CGI#out</code>.
<P></P>
<table bgcolor="#fff0f0" cellspacing="0" border="0" cellpadding="3" width="400"><tr><td><pre>
require "cgi"
cookie = CGI::Cookie.new("rubyweb", "CustID=123", "Part=ABC");
cgi = CGI.new("html3")
cgi.out( "cookie" => [cookie] ){
cgi.html{
"\nHTML content here"
}
}
</pre></td></tr></table>
<em>produces:</em>
<table bgcolor="#fff0f0" cellspacing="0" border="0" cellpadding="3" width="400"><tr><td><pre>
Content-Type: text/html
Content-Length: 86
Set-Cookie: rubyweb=CustID%3D123&Part%3DABC; path=
<P></P>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><HTML>
HTML content here</HTML>
</pre></td></tr></table>
<P></P>
The next time the user comes back to this page, you can retrieve
the cookie values for <code>CustID</code> and <code>Part</code>, as shown in the
HTML output.
<P></P>
<table bgcolor="#fff0f0" cellspacing="0" border="0" cellpadding="3" width="400"><tr><td><pre>
require "cgi"
cgi = CGI.new("html3")
cgi.out{
cgi.html{
cgi.pre{
cookie = cgi.cookies["rubyweb"]
"\nCookies are\n" + cookie.value.join("\n")
}
}
}
</pre></td></tr></table>
<em>produces:</em>
<table bgcolor="#fff0f0" cellspacing="0" border="0" cellpadding="3" width="400"><tr><td><pre>
Content-Type: text/html
Content-Length: 111
<P></P>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><HTML><PRE>
Cookies are
CustID=123
Part=ABC</PRE></HTML>
</pre></td></tr></table>
<h3>Sessions</h3>
<P></P>
Cookies by themselves still need a bit of work to be useful.
What
we really want is a <em>session:</em> a persistent state for some Web
surfer. Sessions are handled with <code>CGI::Session</code>
(documented beginning on page 508), which uses cookies
but provides a higher-level abstraction.
<P></P>
<table bgcolor="#fff0f0" cellspacing="0" border="0" cellpadding="3" width="400"><tr><td><pre>
<P></P>
require "cgi"
require "cgi/session"
<P></P>
cgi = CGI.new("html3")
sess = CGI::Session.new( cgi, "session_key" => "rubyweb",
"session_id" => "9650",
"new_session" => true,
"prefix" => "web-session.")
sess["CustID"] = 123
sess["Part"] = "ABC"
<P></P>
cgi.out{
cgi.html{
"\nHTML content here"
}
}
</pre></td></tr></table>
<P></P>
This will send a cookie to the user named ``rubyweb'' with a value of
9650. It will also create a disk file in <code>$TMP/web-session.9650</code>
with the <em>key, value</em> pairs for <code>CustID</code> and <code>Part</code>.
<P></P>
When the user returns, all you need is a parameter to indicate the
session id. In this example, that would be <code>rubyweb=9650</code>. With
that value in the parameters, you'll be able to retrieve the full
set of saved session data.
<P></P>
<table bgcolor="#fff0f0" cellspacing="0" border="0" cellpadding="3" width="400"><tr><td><pre>
require "cgi"
require "cgi/session"
<P></P>
cgi = CGI.new("html3")
sess = CGI::Session.new( cgi, "session_key" => "rubyweb",
"prefix" => "web-session.")
cgi.out{
cgi.html{
"\nCustomer #{sess['CustID']} orders an #{sess['Part']}"
}
}
</pre></td></tr></table>
<h2>Embedding Ruby in HTML</h2>
<P></P>
So far we've looked at using Ruby to create HTML output, but we can
turn the problem inside out; we can actually embed Ruby in an HTML
document.
<P></P>
There are a number of packages that allow you to embed Ruby
statements in some other sort of a document, especially in an HTML
page. Generically, this is known as ``eRuby.'' Specifically, there
are several different implementations of eRuby, including <code>eruby</code>
and <code>erb</code>. The remainder of this section will discuss <code>eruby</code>,
written by Shugo Maeda.
<P></P>
Embedding Ruby in HTML is a very powerful concept---it basically gives
us the equivalent of a tool such as ASP, JSP, or PHP, but with the
full power of Ruby.
<h3>Using eruby</h3>
<P></P>
<code>eruby</code> acts as a filter, plain and simple. Any text within the input
file is passed through untouched, with the following exceptions:
<P></P>
<table bgcolor="#fff0f0" cellspacing="0" border="0" cellpadding="3">
<tr bgcolor="#ff9999">
<td valign="top"><b>Expression</b></td>
<td valign="top"><b>Description</b></td>
</tr>
<tr>
<td valign="top"><code><%</code> <em>ruby code</em> <code>%></code></td>
<td valign="top">The Ruby code between the delimiters
is replaced with its output.</td>
</tr>
<tr>
<td valign="top"><code><%=</code> <em>ruby expression</em> <code>%></code></td>
<td valign="top">The Ruby expression
between the delimiters is replaced with its value.</td>
</tr>
<tr>
<td valign="top"><code><%#</code> <em>ruby code</em> <code>%></code></td>
<td valign="top">The Ruby code between the
delimiters is ignored (useful for testing).</td>
</tr>
<tr><td colspan="9" bgcolor="#ff9999" height="2"><img src="dot.gif" width="1" height="1"></td></tr></table>
<P></P>
You invoke <code>eruby</code> as:
<P></P>
<table bgcolor="#fff0f0" cellspacing="0" border="0" cellpadding="3" width="500"><tr><td><pre>
eruby <i>[</i><i>options</i><i>]</i> <i>[</i><i>document</i><i>]</i>
</pre></td></tr></table>
<P></P>
If the <em>document</em> is omitted, <code>eruby</code> will read from standard
input. The command-line options for <code>eruby</code> are shown in Table
14.1 on page 151.
<table border="2" width="500" bgcolor="#ffe0e0"><tr><td>
<b>Command-line options for <code>eruby</code></b>
<table bgcolor="#fff0f0" cellspacing="0" border="0" cellpadding="3">
<tr bgcolor="#ff9999">
<td valign="top"><b>Option</b></td>
<td valign="top"><b>Description</b></td>
</tr>
<tr>
<td valign="top"><code>-d</code>, <code>--debug</code></td>
<td valign="top">Sets $DEBUG to <code>true</code>.</td>
</tr>
<tr>
<td valign="top"><code>-K</code><em>kcode</em></td>
<td valign="top">Specifies an alternate coding system
(see page 139).</td>
</tr>
<tr>
<td valign="top"><code>-M</code><em>mode</em></td>
<td valign="top">Specifies runtime <em>mode</em>, one of:
<P></P>
<table bgcolor="#fff0f0" cellspacing="0" border="0" cellpadding="3">
<tr>
<td valign="top"><code>f</code></td>
<td valign="top">filter mode</td>
</tr>
<tr>
<td valign="top"><code>c</code></td>
<td valign="top">CGI mode (prints errors as HTML, sets $SAFE=1)</td>
</tr>
<tr>
<td valign="top"><code>n</code></td>
<td valign="top">NPH-CGI mode (prints extra HTTP headers, sets $SAFE=1)</td>
</tr>
<tr>
<td valign="top"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top"><code>-n</code>, <code>--noheader</code></td>
<td valign="top">Disables CGI header output.</td>
</tr>
<tr>
<td valign="top"><code>-v</code>, <code>--verbose</code></td>
<td valign="top">Enables verbose mode.</td>
</tr>
<tr>
<td valign="top"><code>--version</code></td>
<td valign="top">Prints version information and exits.</td>
</tr>
<tr><td colspan="9" bgcolor="#ff9999" height="2"><img src="dot.gif" width="1" height="1"></td></tr></table>
<P></P>
</td></tr></table>
<P></P>
Let's look at some simple examples. We'll run the <code>eruby</code> executable
on the following input.
<P></P>
<table bgcolor="#fff0f0" cellspacing="0" border="0" cellpadding="3" width="400"><tr><td><pre>
This text is <% a = 100; puts "#{a}% Live!" %>
</pre></td></tr></table>
<P></P>
<code>eruby</code> substitutes the expression between the delimiters and
produces
<P></P>
<table bgcolor="#fff0f0" cellspacing="0" border="0" cellpadding="3" width="400"><tr><td><pre>
This text is 100% Live!
</pre></td></tr></table>
<P></P>
Using the <%= form acts as if you printed the value of the
expression. For instance, the input
<P></P>
<table bgcolor="#fff0f0" cellspacing="0" border="0" cellpadding="3" width="400"><tr><td><pre>
<%a = 100%>This text is almost <%=a%> degrees! Cool!
</pre></td></tr></table>
<P></P>
replaces the <code>=a</code> with the value of <code>a</code>.
<P></P>
<table bgcolor="#fff0f0" cellspacing="0" border="0" cellpadding="3" width="400"><tr><td><pre>
This text is almost 100 degrees! Cool!
</pre></td></tr></table>
<P></P>
And, of course, you can embed Ruby within a more complex document type,
such as HTML.
<P></P>
<table bgcolor="#fff0f0" cellspacing="0" border="0" cellpadding="3" width="400"><tr><td><pre>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>eruby example</title>
</head>
<body>
<h1>Enumeration</h1>
<ul>
<%(1..10).each do|i|%>
<li>number <%=i%></li>
<%end%>
</ul>
<h1>Environment variables</h1>
<table>
<%ENV.keys.sort.each do |key|%>
<tr>
<th><%=key%></th><td><%=ENV[key]%></td>
</tr>
<%end%>
</table>
</body>
</html>
</pre></td></tr></table>
<h3>Installing eruby in Apache</h3>
<P></P>
You can set up an Apache Web server to automatically parse
Ruby-embedded documents using eRuby, much in the same way that PHP
does. You create Ruby-embedded files with an ``<code>.rhtml</code>'' suffix
and configure the Web server to run the <code>eruby</code> executable on these
documents to produce the desired HTML output.
<P></P>
In order to use <code>eruby</code> with the Apache Web server, you need to
perform the following steps.
<P></P>
<ul>
<li> Copy the <code>eruby</code> binary to the <code>cgi-bin</code> directory.
<P></P>
</li><li> Add the following two lines to <code>httpd.conf</code>:
<P></P>
<table bgcolor="#fff0f0" cellspacing="0" border="0" cellpadding="3" width="400"><tr><td><pre>
AddType application/x-httpd-eruby .rhtml
Action application/x-httpd-eruby /cgi-bin/eruby
</pre></td></tr></table>
<P></P>
</li><li> If desired, you can also add or replace the <code>DirectoryIndex</code>
directive such that it includes <code>index.rhtml</code>. This lets you use
Ruby to create directory listings for directories that do not
contain an <code>index.html</code>. For instance, the following directive
would cause the embedded Ruby script <code>index.rhtml</code> to be searched
for and served if neither <code>index.html</code> nor <code>index.shtml</code> existed in a
directory.
<P></P>
<table bgcolor="#fff0f0" cellspacing="0" border="0" cellpadding="3" width="400"><tr><td><pre>
DirectoryIndex index.html index.shtml index.rhtml
</pre></td></tr></table>
<P></P>
Of course, you could also simply use a site-wide Ruby script as
well.
<P></P>
<table bgcolor="#fff0f0" cellspacing="0" border="0" cellpadding="3" width="400"><tr><td><pre>
DirectoryIndex index.html index.shtml /cgi-bin/index.rb
</pre></td></tr></table>
<P></P>
</li></ul>
<P></P>
And that's it! You can now write HTML documents that contain embedded
Ruby to generate forms and content dynamically. Be sure to see also
the Ruby <code>CGI</code> library, which is documented
beginning on page 501.
<h2>Improving Performance</h2>
<P></P>
You can use Ruby to write CGI programs for the Web, but, as with most
CGI programs, the default configuration has to start up a new copy of
Ruby with every cgi-bin page access.
That's expensive in terms of
machine utilization and can be painfully slow for Web surfers.
The Apache Web server solves this problem by allowing loadable
<em>modules</em>.
<P></P>
Typically, these modules are dynamically loaded and become part of the
running Web server process---there is no need to spawn
another interpreter over and over again to service requests; the Web
server <em>is</em> the interpreter.
<P></P>
And so we come to <code>mod_ruby</code> (available from the archives), an
Apache module that links a full Ruby interpreter into the Apache Web
server itself. The <code>README</code> file included with <code>mod_ruby</code> provides
details on how to compile and install it.
<P></P>
Once installed and configured, you can run Ruby scripts just like you
could without <code>mod_ruby</code>, except that now they will come up much
faster.
<P></P>
<p></p><hr><table bgcolor="#a03030" cellpadding="10" border="0" cellspacing="0"><tr><td width="33%" align="left"><a class="subheader" href="rubyworld.html">Previous <</a></td><td width="33%" align="center" valign="middle"><a class="subheader" href="index.html">Contents ^</a><br></td><td width="33%" align="right"><a class="subheader" href="ext_tk.html">Next ></a><br></td></tr></table><p></p><font size="-1">Extracted from the book "Programming Ruby -
The Pragmatic Programmer's Guide"</font><br><font size="-3">
Copyright
©
2000 Addison Wesley Longman, Inc. Released under the terms of the
<a href="http://www.opencontent.org/openpub/">Open Publication License</a> V1.0.
<br>
This reference is available for
<a href="http://www.pragmaticprogrammer.com/ruby/downloads/book.html">download</a>.
</font></body></html>
|