Mason Mod_Perl2.0 Apache 2.0 Fedora Core 1 AMD64 - HOW I DID IT! -
dave_at_subcreations.com
Date: 02/23/05
- Previous message: junnuthala: "Re: Compare huge XML Files"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 23 Feb 2005 14:19:15 -0800
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
#handshake.pl
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
$interp->exec($comp);
#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.
#/var/log/httpd/error_log
-snip
[Wed Feb 23 09:43:58 2005] [error] [client 192.168.0.101] malformed
header from script. Bad header= Greetings, Martians: handshake.pl
[Wed Feb 23 09:43:58 2005] [warn] /perl/handshake.pl did not send an
HTTP header
-endsnip
The test just hadn't printed the header, but otherwise everything was
fine.
Before the second test, it was necessary to reconfigure httpd.conf.
This consisted of adding the following:
#/etc/httpd/conf/httpd.conf
-snip
PerlModule HTML::Mason::ApacheHandler
Alias /m /var/www/html/mason/
<Directory /var/www/html/mason>
SetHandler perl-script
PerlHandler HTML::Mason::ApacheHandler
</Directory>
-endsnip
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/Request.pm"
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 Makefile.pl 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
"PerlResponseHandler".
FOR EXAMPLE:
CHANGE:
#httpd.conf
-snip
Alias /perl /var/www/perl/
<Directory /var/www/perl>
SetHandler perl-script
PerlHandler ModPerl::Registry
PerlSendHeader on
Options ExecCGI
</Directory>
-endsnip
TO
#httpd.conf
-snip
Alias /perl /var/www/perl/
<Directory /var/www/perl>
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlSendHeader on
Options ExecCGI
</Directory>
#endsnip
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
httpd.conf:
#httpd.conf
-snip
LoadModule apreq_module /usr/lib64/httpd/modules/mod_apreq.so
-endsnip
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,
"libapreq2.so.2".
It turned out out that when libapreq2-2.04-dev was installing it put
libapreq2.so.2 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.
<!-- 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!
- Previous message: junnuthala: "Re: Compare huge XML Files"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|