Mason
Configuring Mason on your Dreamhost website.
Contents |
Considerations
Dreamhost does not currently run mod_perl. Therefore, this approach assumes you will be writing your own handler for Mason requests. See the Mason Administrator's Manual for full details and other approaches. This also assumes you are comfortable on the command line.
Mason with FastCGI
Mason can run under FastCGI as easily as under CGI and it's much faster that way. This page has further discussion on way way to do that. It provides a more plug-and-play method of running Mason then the one presented here. (And it can be used with regular CGI as well, if you prefer.)
Directory Setup
Create a cgi-bin for the handler, and the mason directory for objects and cache files. For instance:
# mkdir ~/SITENAME/cgi-bin # mkdir ~/mason # mkdir ~/mason/obj # mkdir ~/mason/cache
Mason CGIHandler
At ~/SITENAME/cgi-bin/mason_handler.cgi, create this file and chmod it 755. Note that the data_dir points to the mason directory we just created in the previous step:
#!/usr/bin/perl
use HTML::Mason::CGIHandler;
# this section optional, ties in custom perl modules
{
package HTML::Mason::Commands;
# anything you want available to components
use lib qw(/home/username/perlmods/lib/perl/site_perl);
use Module::Name;
}
my $h = HTML::Mason::CGIHandler->new
(
data_dir => '/home/USERNAME/mason',
);
$h->handle_request
Configure .htaccess
This is a very basic sample .htaccess file that serves up .mhtml files through Mason, and blocks access to component files (.mas) and the handler files. Salt to taste.
DirectoryIndex index.mhtml index.cgi index.html index.htm index.html.var
AddHandler html-mason .mhtml
Action html-mason /cgi-bin/mason_handler.cgi
<FilesMatch "\.(mas)|autohandler|dhandler$">
Order allow,deny
Deny from all
</FilesMatch
Testing
Create an index.html file and make sure Mason serves it up correctly. Watch the logs. Good luck!