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

i just installed mod_perl to *hopefully* get better speeds.

I've checked the mod_perl manual, read these forums, but i still can't find the right answer i'm looking for...

how can i tell that mod_perl is working?

my perl scripts are running fine from apache, and looking at the environment vars, SERVER_SOFTWARE returns mod_perl -- but i dunno if they're being interpreted/cached by mod_perl or if they're still calling up the system's interpreter each time, because of my inadequcies editing httpd.conf

Replies are listed 'Best First'.
Re: How can i tell if mod_perl is working?
by kschwab (Vicar) on Sep 01, 2002 at 00:28 UTC
    You could print out your pid.
    print "my pid is $$ <br>\n";
    I would suspect your pid would be the same as one of the httpd daemons if mod_perl were running correctly.

    Update:

    Also, from the mod_perl faq:

    How can I test that my script is running under mod_perl?
    
    There are 2 environment variables you can test.
    
    exists $ENV{"MOD_PERL"}   # if running under mod_perl
    
    $ENV{"GATEWAY_INTERFACE"} eq "CGI-Perl/1.1"
    
    The MOD_PERL variable gets set immediately when the perl
    interpreter starts up, whereas GATEWAY_INTERFACE may not be
    set yet when BEGIN blocks are being processed. 
    
Re: How can i tell if mod_perl is working?
by fuzzyping (Chaplain) on Sep 01, 2002 at 00:54 UTC
    Beyond the excellent suggestions offered by kschwab, I'd suggest you configure perl_mod/apache to use scripts from a separate directory. Only store scripts in the perl_mod directory that you want to run via perl_mod... this way you can be assured your script is being compiled by mod_perl, rather than as a normal cgi. If you're having problems configuring your httpd.conf, here's a snippet from mine. Note that I'm using DSO modules... if your mod_perl is compiled into Apache, ignore the IfModule directive.
    PerlModule Apache::DBI PerlTaintCheck On <IfModule mod_perl.c> Alias /p /var/www/p <Directory /var/www/p> SetHandler perl-script PerlHandler Apache::Registry Options +ExecCGI </Directory> </IfModule>
    Good Luck!

    -fp
      well, i wanted apache to run all cgi under mod_perl -- this isn't a web box, its my tibook running osx

      freaking thing is just 101 nightmares and then some more

      i think i'm just gonna recompile apache on it... i tried kscwab's ideas - which are great. but it was starting a new interpreter. so i asked some friends. they tried too - mod_perl comes prebuilt on osx too - and their machines were just running new interpreters too.

      anyways, thanks for all your help. you're all rockstars in my book. damn osx. this is almost worse than trying to compile python on this machine

        well, i wanted apache to run all cgi under mod_perl
        That's not feasible in any real situtation. CGI is still necessary, both for misbehaving Perl programs that don't play well with Apache::Registry, and for non-Perl programs!

        Remember, Apache::Registry (what most people call "running under mod_perl") is just a tiny bit of mod_perl, and it has very explicit restrictions to accomplish its task. You're definitely not even touching the power of mod_perl until you learn to plug in some more advanced structures, like Apache::Template or writing your own handlers.

        -- Randal L. Schwartz, Perl hacker

        Have you tried ApacheToolbox yet? Wonderful stuff!

        UPDATE:
        Hmmmm, i am not, however, positive that ApacheToolbox will work on an OSX box ... sorry if it does not. :(

        jeffa

        L-LL-L--L-LL-L--L-LL-L--
        -R--R-RR-R--R-RR-R--R-RR
        B--B--B--B--B--B--B--B--
        H---H---H---H---H---H---
        (the triplet paradiddle with high-hat)
        
Re: How can i tell if mod_perl is working?
by nmerriweather (Friar) on Sep 01, 2002 at 00:34 UTC
    i feel like an idiot i guess i was staring at getting lost in the docs, i couldn't see it staring me right in the face thanks a ton!