=pod =head1 NAME Apache2::ASP::Manual::HttpdConf - Documentation about httpd.conf for Apache2::ASP =head1 DESCRIPTION To run Apache2::ASP under Apache, you need to set up the Apache configuration properly. Apache configuration takes place in its C file. Although you I simply place your configuration in the main C file, it is recommended that you instead use your local C file located under your application's root in C. To include your local C file in the global C, simply add the following line near the bottom of your global C: # Config for Apache2::ASP application: Include /path/to/your/app/conf/httpd.conf The comment is important as well. =head1 EXAMPLE The following is an example C: # !IMPORTANT! # This is the libapreq2 config entry: LoadModule apreq_module /usr/local/apache2/modules/mod_apreq2.so # !IMPORTANT! # This must be set before Apache2::ASP::PostConfigHandler is run: PerlSetEnv APACHE2_ASP_APPLICATION_ROOT /var/www # Load up some important modules: PerlModule Apache2::ASP PerlModule Apache2::ASP::PostConfigHandler PerlPostConfigHandler Apache2::ASP::PostConfigHandler # Configuration for MediaManager: PerlModule Apache2::ASP::TransHandler # Main website: # !IMPORTANT! # ServerName is not *required* for Apache2::ASP # but is included here in the example, just as an example. # *IF* you do include the ServerName directive, make sure it is correct! ServerName whatever.com # Where your *.asp scripts live: DocumentRoot /var/www/html # Set the directory index, so that /foldername/ will map to /foldername/index.asp: DirectoryIndex index.asp # Apache2::ASP::TransHandler converts /media/filename.txt urls so that they # really mean /handlers/MediaManager?file=filename.txt PerlTransHandler Apache2::ASP::TransHandler # !IMPORTANT! Prevent anyone from viewing your GlobalASA.pm Order allow,deny Deny from all # All *.asp files are handled by Apache2::ASP SetHandler perl-script PerlHandler Apache2::ASP # All requests to /handlers/* will be handled by their respective handler: SetHandler perl-script PerlHandler Apache2::ASP =head1 WALKTHROUGH Here, we'll walk through the configuration step-by-step so that you know what each directive is for. # !IMPORTANT! # This is the libapreq2 config entry: LoadModule apreq_module /usr/local/apache2/modules/mod_apreq2.so Apache2::ASP uses L which requires L. L is part of the C distribution. B if you have B already loaded up C somewhere else in your global C file. C<-------------------------------------------------------------------------------> # !IMPORTANT! # This must be set before Apache2::ASP::PostConfigHandler is run: PerlSetEnv APACHE2_ASP_APPLICATION_ROOT /var/www This line sets C<$ENV{APACHE2_ASP_APPLICATION_ROOT}> to the value C Well, of course you already knew that. This is important because L has only limited abilities in guessing where you might have placed your web application. If this value is completely wrong, you might get an error in your server's error log that looks like this: Cannot find configuration file anywhere! It should be found at $ENV{APACHE2_ASP_APPLICATION_ROOT}/conf/apache2-asp-config.xml Don't panic - just make sure that you have set C correctly to the top-level path of your B not your website's html directory. While you're at it, make sure you take a look at the B section of L or L. C<-------------------------------------------------------------------------------> # Load up some important modules: PerlModule Apache2::ASP PerlModule Apache2::ASP::PostConfigHandler First we simply load up C and C. Then, you see the line: PerlPostConfigHandler Apache2::ASP::PostConfigHandler C may stand out as something very foreign to you. That's ok. We're just telling the Apache webserver to execute L's C method once its done reading the C files, but B it has spawned any child threads or processes. L is in charge of loading up your C file B (and only once). C<-------------------------------------------------------------------------------> # Configuration for MediaManager: PerlModule Apache2::ASP::TransHandler L has the simple job of converting URLs that look like this: /media/yourfile.jpg Into URLs that look like this: /handlers/MediaManager?file=yourfile.jpg So here we load up it up via C but we haven't yet done anything with it. That comes several lines later. C<-------------------------------------------------------------------------------> # Main website: We make a VirtualHost here. If you're not sure what that is, go ahead and Google it sometime. The main idea is that all the other configuration directives we use within the C tags will not affect any other C configurations on your server. C<-------------------------------------------------------------------------------> # !IMPORTANT! # ServerName is not *required* for Apache2::ASP # but is included here in the example, just as an example. # *IF* you do include the ServerName directive, make sure it is correct! ServerName whatever.com This is pretty self-explanatory. Change I to whatever you are calling your website's hostname when you type its hostname into your browser. If you're not sure, just Google it. C<-------------------------------------------------------------------------------> # Where your *.asp scripts live: DocumentRoot /var/www/html This should be pretty clear as well. C<-------------------------------------------------------------------------------> # Set the directory index, so that /foldername/ will map to /foldername/index.asp: DirectoryIndex index.asp Use C because we're doing an Apache2::ASP website. C<-------------------------------------------------------------------------------> # Apache2::ASP::TransHandler converts /media/filename.txt urls so that they # really mean /handlers/MediaManager?file=filename.txt PerlTransHandler Apache2::ASP::TransHandler We've already loaded up L but this line says "only do the url-translation for B website." C<-------------------------------------------------------------------------------> # !IMPORTANT! Prevent anyone from viewing your GlobalASA.pm Order allow,deny Deny from all If you don't do this, someone could read your C as plaintext. Probably not a good thing. C<-------------------------------------------------------------------------------> # All *.asp files are handled by Apache2::ASP SetHandler perl-script PerlHandler Apache2::ASP Tells Apache that any requests that look like C<.asp> should be handled by L. C<-------------------------------------------------------------------------------> # All requests to /handlers/* will be handled by their respective handler: SetHandler perl-script PerlHandler Apache2::ASP Tells Apache that any requests to C should be handled by L. Remember, L will just prepare the ASP environment and then call your Handler module which would be located under your C directory. For Linux installations see L. For Windows installations see L. C<-------------------------------------------------------------------------------> Tells Apache that none of the configuration options we've set within the C tags above should affect any of the other C setups you have on the same server. =head1 BUGS It's possible that some bugs have found their way into this release. Use RT L to submit bug reports. =head1 HOMEPAGE Please visit the Apache2::ASP homepage at L to see examples of Apache2::ASP in action. =head1 AUTHOR John Drago L =head1 COPYRIGHT AND LICENSE Copyright 2007 John Drago, All rights reserved. This software is free software. It may be used and distributed under the same terms as Perl itself. =cut