Flame has asked for the wisdom of the Perl Monks concerning the following question:

This question is not strictly Perl related as far as I know, but I don't know who else to turn to. Also, as far as I know, this question has already been answered, if so, I'm sorry but I wasn't able to find it.

I am attempting to use HTML::Mason on a school project, however I don't have acess to mod_perl (can't seem to get it to install on Win32), so I'm falling back on HTML::Mason::CGIHandler. The problem is that while I have followed the instructions in the CGIHandler docs, it doesn't seem to be using the handler script. Below is any information I think may be important... I don't know what else to try since I don't work directaly with Apache too often.

Running Win32 (Win98SE), I'm not sure of the apache version ATM. I'll post it when I get home (posting from school)

Action html-mason /cgi-bin/mason_handler.cgi placed into httpd.conf

Placed into .htaccess

<FilesMatch "\.html$"> SetHandler html-mason </FilesMatch>

mason_handler.cgi
#!perl use HTML::Mason::CGIHandler; warn("Used CGIHandler!"); my $h = new HTML::Mason::CGIHandler ( allow_globals => [qw(%session $u)], ); $h->handle_request;

The warning in the above code never shows up, so I have to guess for now that the problem lies with Apache, but what did I do wrong?

Thanks in advance





My code doesn't have bugs, it just develops random features.

Flame ~ Lead Programmer: GMS | GMS

Replies are listed 'Best First'.
Re: Apache and HTML::Mason::CGIHandler, Not being called?
by rdfield (Priest) on Oct 30, 2002 at 15:24 UTC
    Not having used Mason, I'm "shooting in the dark", but have you made sure that your cgi directory is defined correctly in you httpd.conf file? The htaccess file shown is only to do with html files and has no bearing on the .cgi file shown. Also, do you have perl installed?

    You say you had problems installing mod_perl...can you provide some detail? The install process is very straightforward on Win32, providing that you're using activestate's distro and you've set the repository correctly in PPM (all of the required instuctions are at mod_perl).

    rdfield

      Sit down, this could take a while as I'm not quite sure how to explain the problems I've had with mod_perl :)

      I have tried their PPM method of installation to no avail... while I get all the Apache perl modules, mod_perl itself never installs (I followed their instructions down to a copy-paste.) I attempted to manualy build my own, only to discover that MS-VC++ can't do what MS-DevStuido can, so I can't build it myself. Thus, I had to give up on mod_perl (unless I overlooked an option).

      So, HTML::Mason has a module designed to simulate mod_perl, HTML::Mason::CGIHandler, which you can supposedly tell Apache to use instead of referencing the file itself... the problem is, it's still referencing the file itself. Ie: http://localhost.com/School/test.html

      htdocs/School/test.html contains: <% 1+1 %>

      If mason reads it, it should come out 2, with nothing else. Just 2. Instead I get <% 1+1 %> printed out. So... something is going wrong somewhere along the line. (That .htaccess file is also in htdocs/School)

      Also, I do have the latest version of ActivePerl, though I haven't attempted to install mod_perl since a couple minor revisions ago (circa February release, attempted install only a week ago) The cgi directory is the default, and the one that the installer setup automaticaly.

      I hope this clears a few things up, anything else I should provide?

      Thanks for the suggestions.



      My code doesn't have bugs, it just develops random features.

      Flame ~ Lead Programmer: GMS | GMS

        As I said, I've never used Mason, but from your description it looks like the handler is not being called - which from my understanding would mean that your <FilesMatch> directive is incorrect. You might want to check the access log to make sure that the html file specified is being processed correctly.

        On the mod_perl front, there is one tricky step which is often missed out, so I'll list the steps I use to install mod_perl in Win32 boxen:

        • Download the binary Apache distribution (version 1.3.27 as I haven't progressed to 2.0 yet) from here
        • Run the downloaded installer exe, which by default will install apache in c:\program files\apache group\apache
        • Download the latest activestate Perl distro from Activestate (the .msi file is best)
        • Install the perl msi file, which by default ends up in c:\perl
        • Run cmd if on a WinNT, W2K etc box or command on a 9x box
        • Run ppm at the command line
        • At the PPM prompt enter repository add mod_perl http://theoryx5.uwinnipeg.ca/cgi-bin/ppmserver?urn:/PPMServer
        • At the PPM prompt enter install mod_perl
        • Eventually it will ask where to install the mod_perl library, enter c:/program files/apache group/apache/modules (if this doesn't work, find mod_perl.so and copy it manually into this directory)
        • Uncomment the perl module lines in the apache httpd.conf (if they're not there add the lines LoadModule modules/mod_perl.so and AddModule mod_perl.c to the appropriate sections)
        • Set up an appropriate perl handler:
          Alias /perl/ "/some/dir/on/my/disk/" <Location /perl> SetHandler perl-script PerlHandler Apache::Registry AddHandler perl-script .pl Options +ExecCGI PerlSendHeader On </Location>
        • and any .pl files in your /some/dir/on/my/disk/ directory will be handled by mod_perl.
        Hope this helps.

        rdfield

        Update: Corrected reference from mod_perl.dll to mod_perl.so