Chris,
Thanks a lot for the advice. I will keep it and read it again when I install
AxKit.


ted
On Mar 10, 2005, at 4:52 PM, Chris Devers wrote:

On Thu, 10 Mar 2005, Ted Zeng wrote:

Thanks. I turned it on by following your advice.

There was more to it than that though.

Merely turning it on by uncommenting the LoadModule and AddModule
statements adds the functionality to Apache, but unless you also have
directives that take advantage of it, it will sit there, silent & inert.


So, you also need one or more blocks of directives that use mod_perl;
the details will vary depending on your goals, but here's a simple block
that will allow you to rename most Perl .cgi or .pl scripts to run under
the Apache::Registry mod_perl module if you rename them to *.mpl :


<IfModule mod_perl.c>
PerlHeaderParserHandler "sub { tie *STDOUT, 'Apache' unless tied *STDOUT; }"
PerlHandler Apache::Registry
<Files *.mpl>
PerlRequire /etc/httpd/startup.pl
SetHandler perl-script
Options +ExecCGI
</Files>
</IfModule>


Most people prefer to put all CGI / mod_perl scripts in one directory,
but I prefer handling them by file extension, the way Windows or OSX
would do. A more conventional approach might look like this instead:

<IfModule mod_perl.c>
PerlHeaderParserHandler "sub { tie *STDOUT, 'Apache' unless tied *STDOUT; }"
PerlHandler Apache::Registry
Alias /perl/ "/Library/WebServer/Perl/"
<Directory /Library/WebServer/Perl>
PerlRequire /etc/httpd/startup.pl
SetHandler perl-script
Options +ExecCGI
</Directory>
</IfModule>


Hopefully this gets the idea across.

Note that both of these refer to /etc/httpd/startup.pl. This script just
preloads modules when Apache is launched, so that their contents are
alreaddy available in memory when page hits start coming in. My copy of
this file is pretty simple:


    #!/usr/bin/perl -w

    # lifted from the eagle book, pages 28 & 29

    BEGIN {
        use Apache ();
        use lib qw( /sw/lib/perl5 );
        tie *STDOUT, 'Apache';
    }

    use Apache::Registry ();
    use Apache::Constants();
    use CGI qw(-compile:all);
    use CGI::Carp ();

    use Apache::DBI();
    use Apache::MP3::Sorted();

    1;

Modules you use a lot can be addded here to improve performance, but
adding too much can slow all accesses down. Balance accordingly.

Hopefully, the package you're setting up -- AxKit in this case -- will
have instructions for what it needs to have added to your httpd.conf in
order to meet its mod_perl needs.



--
Chris Devers




Reply via email to