File: libhtml-mason-perl.README.Debian

package info (click to toggle)
libhtml-mason-perl 1%3A1.26-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,636 kB
  • ctags: 1,260
  • sloc: perl: 13,880; sh: 154; makefile: 47
file content (137 lines) | stat: -rw-r--r-- 4,806 bytes parent folder | download
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
HTML::Mason Debian package
==========================

This document now contains information on usage with mod_perl, and on
usage with SpeedyCGI (or indeed normal CGI, but you'd been insane to
use that IMHO).

Tests 5 and 6 of t/10-cache have been known to fail apparently
randomly, but never when I've tried running them with debug messages
turned on (grr).

The full Mason manual is in package libhtml-mason-perl-doc, and the
example components mentioned in this file are in package
libhtml-mason-perl-examples.

Using Mason with Apache2 (and hence mod_perl2) is currently
non-trivial. Full Mason support for mod_perl2 is currently being
worked on, see http://www.masonhq.com/?ApacheModPerl2

Using HTML::Mason with mod_perl
-------------------------------

Since version 1.10 (or so), HTML::Mason has been much easier to set
up-- it can now be done entirely in the httpd.conf file. Simply add a
section like this to httpd.conf:

  PerlModule HTML::Mason::ApacheHandler
  <Directory /var/www>
   <FilesMatch "\.m$">
    SetHandler perl-script
    PerlHandler HTML::Mason::ApacheHandler
    DefaultType text/html
   </FilesMatch>
   PerlSetVar MasonCompRoot /var/www
   IndexIgnore autohandler dhandler
   AddIcon (TXT,/icons/text.gif) .m
  </Directory>

This will make all .m files under /var/www be processed as Mason
components. Compiled objects will go into /var/lib/mason, which should
have been automagically created and chowned to www-data:www-data.

If you want all files under a specific directory to be processed as
components, try sth like:

  <Directory /my/mason/app>
    PerlSetVar MasonCompRoot /my/mason/app
    PerlSetVar MasonDataDir /my/mason/datadir
    SetHandler perl-script
    PerlHandler HTML::Mason::ApacheHandler
  </Directory>

If MasonDataDir is not specified, the data directory will default to
/etc/apache/mason, which in this package is a symlink to
/var/lib/mason. If you are setting MasonCompRoot, you should almost
definitely set MasonDataDir as well-- otherwise two components with
the same path in two different areas would get the same compiled code,
not good.

Using HTML::Mason with SpeedyCGI
--------------------------------

You need to install speedy-cgi-perl. You don't need
libapache-mod-speedycgi, we'll just use the normal CGI module to
execute the speedy script, which will start the speedy_backend up
itself.

In httpd.conf, enable mod_actions and configure like this:

Action html-mason /cgi-bin/mason-handler.cgi
<Location /mason_cgi_example/>
 SetHandler html-mason
</Location>
AddHandler .m html-mason

As before, this will make all .m files under /var/www be processed as
Mason components, by passing them to /cgi-bin/mason-handler.cgi.

Reload apache's config file (apachectl graceful).

Write /usr/lib/cgi-bin/mason-handler.cgi:

==== Available as /usr/share/doc/libhtml-mason-perl/examples/speedycgi-handler.cgi
#!/usr/bin/speedy
# -*- perl -*-

use HTML::Mason::CGIHandler;
use CGI::Cookie;

BEGIN { warn "Loading mason-handler.cgi"; };
warn "Executing mason-handler.cgi";

my $h = HTML::Mason::CGIHandler->new(data_dir => "/var/lib/mason");

$h->handle_request;
====

Obviously, you can take out the "warn" lines in real use, but for
testing this will demonstrate that mason-handler.cgi itself is only
loaded once.

You may need to chmod +x /usr/lib/cgi-bin/mason-handler.cgi.

Remember that stopping Apache does not kill off the speedy_backend
processes!

Using Mason via CGI entirely from .htaccess files in your public_html
directory-- getting somewhat arcane now, but try something like:

# /home/shaslam/public_html/mason_test/.htaccess:
RewriteEngine On
RewriteBase /~shaslam/mason_test/
RewriteRule ^mason_example_cgi/$ /~shaslam/mason_test/mason_handler.cgi/mason_example/index.html
RewriteRule ^mason_example_cgi/(.+)/$ /~shaslam/mason_test/mason_handler.cgi/mason_example/$1/index.html
RewriteRule ^mason_example_cgi/(.+) /~shaslam/mason_test/mason_handler.cgi/mason_example/$1
Options +ExecCGI
AddHandler cgi-script .cgi

And mason_handler.cgi must specify 'comp_root =>
"/home/shaslam/public_html/mason_test"' when constructing the
CGIHandler object.

The fiddling to rewrite requests to /index.html is not necessary if
your URIs really do map to the mason components, because then mod_dir
will do it. OTOH, you need to avoid rewriting requests ending in / in
that case. Something like:

RewriteRule ^mason_example_cgi/(.*[^/]) /~shaslam/mason_test/mason_handler.cgi/mason_example/$1

And then, assuming "mason_example_cgi" is a directory with the
components under it, requests ending in "/" will *not* be rewritten,
so mod_dir will pick them up and look for "index.html" (DirectoryIndex
setting) locations as usual.

In general, this fiddling is not fun for novices.

 -- Steve Haslam <araqnid@debian.org>, Fri Mar  5 13:32:15 2004