Mason Mod_Perl2.0 Apache 2.0 Fedora Core 1 AMD64 - HOW I DID IT! -

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Here's how I got Mason to work with Apache 2.0

In short,

1. get Mason

2. get libapreq2-2.04-dev

3. get mod_perl-2.0-current.tar.gz

I am using Fedora Core 1 AMD64

I got Mason at CPAN and installed it using:

perl -MCPAN -e shell install HTML:Mason

Following the instructions from the book, "Embedding Perl in HTML with
MASON" by Dave Rolsky & Ken Williams, The first test using the
following Perl script in a mod_perl directory worked fine.

#! /usr/bin/perl
use strict;
use HTML::Mason;
my $interp = HTML::Mason::Interp->new();
my $comp = $interp->make_component(comp_source => <<'END');
 Greetings, <% ("Earthlings", "Martians")[rand 2] %>
#End of Script

This printed the random message intended when executed from the shell
and didn't print anything when executed in the browser.
/var/log/httpd/error_log explains why.

[Wed Feb 23 09:43:58 2005] [error] [client] malformed
header from script. Bad header= Greetings, Martians:
[Wed Feb 23 09:43:58 2005] [warn] /perl/ did not send an
HTTP header

The test just hadn't printed the header, but otherwise everything was

Before the second test, it was necessary to reconfigure httpd.conf.

This consisted of adding the following:


PerlModule HTML::Mason::ApacheHandler
Alias /m  /var/www/html/mason/
<Directory /var/www/html/mason>
    SetHandler perl-script
    PerlHandler HTML::Mason::ApacheHandler

Apache wouldn't start.

There were a number of problems because I am using Apache 2.0.
The first was that the system couldn't find the module:
 "Can't locate Apache/"

Apache 2.0 doesn't seem to come with this library.

Fortunately, there is a new version of libreq (libapreq2-2.04-dev)
available from CPAN that solves this problem.

I downloaded the targz and ran the only to find that I
needed to upgrade mod_perl.

So I downloaded the latest mod_perl (mod_perl-2.0-current.tar.gz) and
ran the Makefile.PL, make and make install.

   This broke the old mod_perl-1.xx configuration in httpd.conf
   The fix is easy. Just change any occurrences of "PerlHandler" to

Alias /perl  /var/www/perl/
<Directory /var/www/perl>
    SetHandler perl-script
    PerlHandler ModPerl::Registry
    PerlSendHeader on
    Options ExecCGI


Alias /perl  /var/www/perl/
<Directory /var/www/perl>
    SetHandler perl-script
    PerlResponseHandler ModPerl::Registry
    PerlSendHeader on
    Options ExecCGI


Note: This change included changing the "PerlHandler" to
"PerlResponseHandler" in the configuration script described in the
Mason Book that I included at the beginning of this post.

So, Great! Apache is working again.  Then I again executed the the
Makefile.PL for
libapreq2-2.04-dev and the make and make install.

Apache still wouldn't start and there was a different error now. Apache
reported a syntax error caused when it got to the following line in

LoadModule apreq_module       /usr/lib64/httpd/modules/

The error was reported in the status window in
System-Settings->Server-Settings->Services when I used the Services
Utility to restart Apache. It said it couldn't find the file,

It turned out out that when libapreq2-2.04-dev was installing it put in /usr/lib instead of /usr/lib64.  I thought it was
strange because it put all the other library files in /usr/lib64.

One other problem I had with libraries was that I needed to move all
Mason Perl modules into the path.

>From my experience with running AMD64, most of the problems I have
installing software are related to certain library files not ending up
in lib64.

I then continued with the next test.

This test consisted of putting the following in the file called

<!-- handshake.html (Entire file) -->

Greetings, <% ("Earthlings", "Martians")[rand 2] %>

<!-- END OF handshake.html  -->

I originally tried creating a "mason" directory (/var/www/mason) that
was not in the document tree (just like I do with my Perl scripts in
the /var/www/perl directory) and using an Alias in httpd.conf but it it
wouldn't work and HTML-Mason-1.28/htdocs/Admin.html made it clear that
this will always be the case.

I wound up putting  handshake.html in another directory that is in the
document tree and the page worked as expected.

It took longer than I expected and I haven't tried anything else yet. I
still think I'm going to have to install Apache 1.3 for some other
reasons though.

Good Luck!

Site Timeline