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

dear monks,

we will make a simple webservice public very soon. this beast now finally runs fine under mod_perl. now I am trying to find the best apache2 configuration. i've taken a simple example from the modperlbook:

<VirtualHost *:80> # default things like doc. root Alias /perl/ /var/www/modperl/ PerlModule ModPerl::Registry <Location /perl/> SetHandler perl-script PerlHandler ModPerl::Registry Options +ExecCGI PerlSendHeader On Allow from all </Location> </VirtualHost>

mod_perl is so powerful, and I am quite sure, many of you with much more experience have made nice virtualhost settings container like i have optimized my .vimrc over the years (bad example ;) ). would be cool to see one of yours. and yes I know that for every webapp the optimal settings are different. but a good start for a not that critical webservice should be possible, or not?

We use a CGI::Application based framework and a MySQL database (just in case this changes something)

ps: sorry if this sounds for you like "I am too lazy to RTFM". probably you are right ;) but time is limited and like i said already, it is not that critical.

Replies are listed 'Best First'.
Re: your mod_perl configurations
by Anonymous Monk on Feb 16, 2006 at 20:26 UTC
    I like to associate mp with .pl files, not locations.
    <IfModule mod_perl.c> PerlTaintCheck On <IfModule mod_mime.c> <FilesMatch \.pl$> SetHandler perl-script PerlHandler Apache::Registry AddHandler perl-script .pl </FilesMatch> </IfModule> <Location /perl-status> SetHandler perl-script PerlHandler Apache::Status </Location> </IfModule>
Re: your mod_perl configurations
by Fletch (Bishop) on Feb 16, 2006 at 20:32 UTC

    The mod_perl Developer Cookbook has a chapter (2, if memory serves me correctly) on configuration and I the sample configs are available for download from the web site in the sample code tarball.

    Update: Oop, I just looked more closely at what they've got available for download and it's not a whole lot from that chapter. The dead tree does have a good bit of discussion on configuration in chapter 2, although I'm not sure it's not somewhat dated with respect to Apache 2 so if you don't already have access to a copy it might not be worth it (then again if you're still using mod_perl 1 it's a very good reference).

Re: your mod_perl configurations
by cbrandtbuffalo (Deacon) on Feb 16, 2006 at 21:39 UTC
    Did you have a specific question or problem you are having? Or did you just want to see some examples?

    Your example looks fine, as long as coders on the system know that if they put things in that directory they will be run under Registry. If you're concerned about limiting this, you can designate specific scripts, as suggested above.

    If you are using a database, you should also look into Apache::DBI. This module manages persistent DB connections and this can give you a significant performance increase. Plus you aren't hitting your DB with constant connects and disconnects.

      my "question" was, are there some useful mod_perl features you can add just in your apache conf instead of changing too much sourcecode. or using other modules instead of this Registry, that protect you from simple DoS attacks, whatever, nice features you use and that i can use and understand without reading 300 pages of the modperl book. sorry if this was a stupid question, I'm a mod_perl newbie.
        Not a stupid question at all; I just wasn't clear what it was. :)

        Registry pretty much does the trick. Some modules to check out are Apache::DBI and possibly Apache::Template.

        As far as getting into special settings in the server, that's where you get advanced. mod_perl gives you full access to Apache internals via perl code in handlers. Once you start writing handlers, you can respond to requests however you like, but you'll need to read a decent amount of documentation before you can really take advantage of these features. Note that this requires knowledge of Apache as much as mod_perl.