The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Mason - High-performance, dynamic web site authoring system</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:root@localhost" />
</head>

<body style="background-color: white">


<!-- INDEX BEGIN -->
<div name="index">
<p><A NAME="__index__"></a></p>

<ul>

	<li><A HREF="#name">NAME</a></li>
	<li><A HREF="#synopsis">SYNOPSIS</a></li>
	<li><A HREF="#description">DESCRIPTION</a></li>
	<li><A HREF="#installation">INSTALLATION</a></li>
	<li><A HREF="#configuring_mason">CONFIGURING MASON</a></li>
	<li><A HREF="#documentation_roadmap">DOCUMENTATION ROADMAP</a></li>
	<li><A HREF="#authors">AUTHORS</a></li>
	<li><A HREF="#copyright">COPYRIGHT</a></li>
	<li><A HREF="#see_also">SEE ALSO</a></li>
</ul>

<hr name="index" />
</div>
<!-- INDEX END -->

<p>
</p>
<h1><A NAME="name">NAME</a></h1>
<p>Mason - High-performance, dynamic web site authoring system</p>
<p>
</p>
<hr />
<h1><A NAME="synopsis">SYNOPSIS</a></h1>
<pre>
    PerlModule HTML::Mason::ApacheHandler</pre>
<pre>
    &lt;Location /&gt;
        SetHandler perl-script
        PerlHandler HTML::Mason::ApacheHandler
    &lt;/Location&gt;</pre>
<p>
</p>
<hr />
<h1><A NAME="description">DESCRIPTION</a></h1>
<p>Mason is a tool for building, serving and managing large web
sites. Its features make it an ideal backend for high load sites
serving dynamic content, such as online newspapers or database driven
e-commerce sites.</p>
<p>Actually, Mason can be used to generate any sort of text, whether for
a web site or not.  But it was originally built for web sites and
since that's why most people are interested in it, that is the focus
of this documentation.</p>
<p>Mason's various pieces revolve around the notion of &quot;components''. A
component is a mix of HTML, Perl, and special Mason commands, one
component per file. So-called &quot;top-level&quot; components represent entire
web-pages, while smaller components typically return HTML snippets for
embedding in top-level components. This object-like architecture
greatly simplifies site maintenance: change a shared component, and
you instantly changed all dependant pages that refer to it across a
site (or across many virtual sites).</p>
<p>Mason's component syntax lets designers separate a web page into
programmatic and design elements. This means the esoteric Perl bits
can be hidden near the bottom of a component, preloading simple
variables for use above in the HTML. In our own experience, this frees
content managers (i.e., non-programmers) to work on the layout without
getting mired in programming details. Techies, however, still enjoy
the full power of Perl.</p>
<p>Mason works by intercepting innocent-looking requests (say,
<a href="http://www.yoursite.com/index.html)">http://www.yoursite.com/index.html)</a> and mapping them to requests for
Mason components.  Mason then compiles the component, runs it, and
feeds the output back to the client.</p>
<p>Consider this simple Mason component:</p>
<pre>
    % my $noun = 'World';
    Hello &lt;% $noun %&gt;!
    How are ya?</pre>
<p>The output of this component is:</p>
<pre>
    Hello World!
    How are ya?</pre>
<p>In this component you see a mix of standard HTML and Mason
elements. The bare '%' prefixing the first line tells Mason that this
is a line of Perl code. One line below, the embedded &lt;%
...&nbsp;%&gt; tag gets replaced with the return value of its contents,
evaluated as a Perl expression.</p>
<p>Beyond this trivial example, components can also embed serious chunks
of Perl code (say, to pull records from a database). They can also
call other components, cache results for later reuse, and perform all
the tricks you expect from a regular Perl program.</p>
<p>
</p>
<hr />
<h1><A NAME="installation">INSTALLATION</a></h1>
<p>Mason has been tested under Linux, FreeBSD, Solaris, HPUX, and
Win32. As an all-Perl solution, it should work on any machine that has
working versions of Perl 5.00503+, mod_perl, and the required CPAN
modules.</p>
<p>Mason has a standard MakeMaker-driven installation. See the README
file for details.</p>
<p>
</p>
<hr />
<h1><A NAME="configuring_mason">CONFIGURING MASON</a></h1>
<p>This section assumes that you are able to install and configure a
mod_perl server. Relevant documentation is available at
<a href="http://www.apache.org">http://www.apache.org</a> (Apache) and <a href="http://perl.apache.org">http://perl.apache.org</a>
(mod_perl). The mod_perl mailing list, archive, and guide are also
great resources.</p>
<p>The simplest configuration of Mason requires a few lines in your
httpd.conf:</p>
<pre>
    PerlModule HTML::Mason::ApacheHandler</pre>
<pre>
    &lt;Location /&gt;
        SetHandler perl-script
        PerlHandler HTML::Mason::ApacheHandler
    &lt;/Location&gt;</pre>
<p>The PerlModule directive simply ensures that the Mason code is loaded
in the parent process before forking, which can save some memory when
running mod_perl.</p>
<p>The &lt;Location&gt; section routes all requests to the Mason handler, which
is a simple way to try out Mason. A more refined setup is discussed
in the <A HREF="Admin.html#controlling_access_via_filename_">Controlling Access via Filename Extension</a> section of the administrator's manual.</p>
<p>Once you have added the configuration directives, restart the
server. First, go to a standard URL on your site to make sure you
haven't broken anything. If all goes well you should see the same page
as before. If not, recheck your Apache config files and also tail your
server's error log.</p>
<p>If you are getting &quot;404 Not Found&quot; errors even when the files clearly
exist, Mason may be having trouble with your document root. One
situation that will unfortunately confuse Mason is if your document
root goes through a symbolic link. Try expressing your document root
in terms of the true filesystem path.</p>
<p>Next, try adding the tag &lt;% 2+2 %&gt; at the top of some HTML file. If you
reload this page and see a &quot;4&quot;, Mason is working!</p>
<p>
</p>
<hr />
<h1><A NAME="documentation_roadmap">DOCUMENTATION ROADMAP</a></h1>
<p>Once Mason is on its feet, the next step is to write a component or
two. The <a HREF="Devel.html">Mason Developer's Manual</a> is a
complete tutorial for writing, using, and debugging components. A
reference companion to the Developer's Manual is the Request API
documentation, <a HREF="Request.html">HTML::Mason::Request</a>.</p>
<p>Whoever is responsible for setting up and tuning Mason should read the
<a HREF="Admin.html">Administrator's Manual</a>, though developers
will also benefit from reading it as well. This document covers more
advanced configuration scenarios and performance optimization. The
reference companion to the Administrator's manual is the
<a HREF="Params.html">Parameters Reference</a>, which describes all the
parameters you can use to configure Mason.</p>
<p>Most of this documentation assumes that you're running Mason on top of
mod_perl, since that is the most common configuration.  If you would
like to run Mason via a CGI script, refer to the
<a HREF="CGIHandler.html">HTML::Mason::CGIHandler</a> documentation.
If you are using Mason from a standalone program, refer to
the <A HREF="Admin.html#using_mason_from_a_standalone_sc">Using Mason from a Standalone Script</a> section of the administrator's manual.</p>
<p>There is also a book about Mason, <em>Embedding Perl in HTML with
Mason</em>, by Dave Rolsky and Ken Williams, published by O'Reilly and
Associates.  The book's website is at <a href="http://www.masonbook.com/.">http://www.masonbook.com/.</a>  This
book goes into detail on a number of topics, and includes a chapter of
recipes as well as a sample Mason-based website.</p>
<p>
</p>
<hr />
<h1><A NAME="authors">AUTHORS</a></h1>
<p>Jonathan Swartz &lt;<a href="mailto:swartz@pobox.com">swartz@pobox.com</a>&gt;, Dave Rolsky &lt;<a href="mailto:autarch@urth.org">autarch@urth.org</a>&gt;, Ken Williams &lt;<a href="mailto:ken@mathforum.org">ken@mathforum.org</a>&gt;, John Williams &lt;<a href="mailto:williams@tni.com">williams@tni.com</a>&gt;</p>
<p>
</p>
<hr />
<h1><A NAME="copyright">COPYRIGHT</a></h1>
<p>Copyright (c) 1998-2005 Jonathan Swartz.  All rights reserved.  This
program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.</p>
<p>The full text of the license can be found in the LICENSE file included
with this module.</p>
<p>
</p>
<hr />
<h1><A NAME="see_also">SEE ALSO</a></h1>
<p><a HREF="Devel.html">HTML::Mason::Devel</a>,
<a HREF="Admin.html">HTML::Mason::Admin</a></p>

</body>

</html>