Using Demo::JBook as an Apache Handler
The Demo::JBook application is going to exist as an Apache mod_perl handler, that is, we’ll use the power of Perl’s integration into the Apache web server to write an Apache module in Perl. You can find out more about mod_perl at http://perl.apache.org.
Being a mod_perl module, Demo::JBook exists in the form of a
Perl module and is
configured in Apache to service calls to
http://[
hostname
]/jbook.
The configuration can be comfortably placed in the main Apache configuration file,
httpd.conf, or, as is common in mod_perl installations,
in an extra file usually called perl.conf, which is linked to httpd.conf as follows:
<IfModule mod_perl.c> Include conf/perl.conf </IfModule>
The configuration for Demo::JBook is placed in the perl.conf file, as shown in Example 10-5.
require conf/startup.pl ... <Location /jbook> SetHandler perl-script PerlHandler Demo::JBook </Location>
The PerlHandler directive refers to the Demo::JBook
module, which is the JBook.pm file that exists in the
Demo/ directory. The module will be invoked to
handle calls to the relative URL /jbook.
You can add the location of
the Demo::JBook module to mod_perl’s list of directories in the
BEGIN section of the startup.pl
script, in the conf/ directory, like this:
BEGIN {
use Apache ();
use lib '[the directory location of Demo::JBook]';
}Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access