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

I installed Apache2 and mod_perl2. I didn't get any errors on install, I ran "make test" and all were successful except 2 were skipped (wwwlib_perl not installed) I added the LoadModule line in httpd.conf, I restarted httpd - worked fine. But when I check the Apache log files it doesn't say mod_perl is running. If I do a AddModule mod_perl.c (as in Apache1.3) I get an error and httpd won't restart, but I don't think I need to do that in Apache2. Anyway, httpd -l doesn't list mod_perl.c, but it's dynamic as mod_perl.so so I shouldn't need .c My question then is: Is mod_perl running if I have LoadModule perl_module  modules/mod_perl.so in the httpd conf and am able to start it without errors even if it doesn't say it's running in the log? Any help would be awesome. P

Replies are listed 'Best First'.
Re: mod_perl.so installed, not running?
by borisz (Canon) on Jul 26, 2004 at 22:17 UTC
    Look into your errorlog file to verify that your mod_perl is running. Another option is to try a
    HEAD http://yourhost/
    and watch your server header. It s enabled by default. Here is my one:
    Server: Apache/2.0.49 (Unix) mod_perl/1.99_14 Perl/v5.8.3 mod_ssl/2.0. +49 OpenSSL/0.9.7d DAV/2 SVN/1.0.2
    Boris
Re: mod_perl.so installed, not running?
by ercparker (Hermit) on Jul 27, 2004 at 03:54 UTC
    here are a couple ways to check if apache is running with mod_perl
    [localhost:~] ericpark% telnet eric 80 Trying 10.0.1.5... Connected to eric. Escape character is '^]'. GET / 1.1 __OUTPUT__ HTTP/1.1 200 OK Date: Tue, 27 Jul 2004 07:10:54 GMT Server: Apache/2.0.48 (Unix) mod_perl/1.99_13 Perl/v5.8.0 PHP/4.3.5
    or check the error log after restarting apache as borisz said
    you can look in the httpd conf file for the location of the error log

    servername# grep mod_perl /var/log/httpd-error.log
    [Tue Jul 27 00:10:37 2004\] \[notice\] Apache/2.0.48 (Unix) mod_perl/1 +.99_13 Perl/v5.8.0 PHP/4.3.5 configured -- resuming normal operations

    here is a great article on perl.com covering installing and configuring mod_perl

      That's right. It'll also show you if you're running the version of Apache you think you are. Ie, make sure you're starting the 2.0 by the full ...apache2/bin/apachectl path if you still have the 1.3 on that box too. Along that line. here is a handy alias I use almost every day when doing webdev stuff: alias ers "tail -f /usr/local/apache2/logs/error_log"

Re: mod_perl.so installed, not running?
by u235sentinel (Hermit) on Jul 27, 2004 at 17:41 UTC
    I had some trouble getting it working with Apache2 and mod_perl2. After fooling around with it I switched to Apache 1.3.x with mod_perl1. Took some tweaking but I was able to get it working fine. I don't believe AddModule works correctly with Apache2. I'm pretty sure LoadModule is the correct way to load modules. Here is how I tested my environment btw.
    print "Content-type: text/plain\r\n\r\n"; print "Server's environment\n"; foreach ( keys %ENV ) { print "$_\t$ENV{$_}\n"; }
    Basically this prints out your environment within Apache. You should see mod_perl as your gateway I believe. Also a setting somewhere for which version of mod_perl you are running. The program should just work without the #! at the top. If it doesn't then try adding it. This means you are not loading mod_perl. It runs fine as is if mod_perl is loaded.

    Some place to start at least.

    After thinking about it, here is an example of what the above produced (edited of course):

    Server's environment
    PERL_SEND_HEADER	On
    SERVER_NAME	test
    SERVER_SOFTWARE	Apache/1.3.31 (Unix) mod_perl/1.29
    GATEWAY_INTERFACE	CGI-Perl/1.1
    MOD_PERL	mod_perl/1.29
    


    Hope this helps
      I tried your script (with and without a #!), but it printed the server environment not apache's and it didn't say anything about mod_perl. Also, if you install apache2 and mod_perl2 without error, add the LoadModule line, but that doesn't work, how else are you supposed to get Apache to recognize mod_perl? Thanks. P
        So you didn't see any of the environment variables such as gateway interface or server software? If that's the case then you might have your environment setup incorrectly.

        I had purchased the "Oreilly Practical Mod_Perl" which helped immensely. Here is some of my httpd.conf referring to this subject. The last section is what you need to pay attention to I believe:
        # MOD_Perl Section <Directory "/usr/local/apache/perllibrary"> AllowOverride None Options ExecCGI Order allow,deny Allow from All </Directory> + ScriptAlias /perl/ "/usr/local/apache/perllibrary/" + <IfModule mod_perl.c> + PerlRequire "/usr/local/apache/perllibrary/startup.pl" + <Location /perl> SetHandler perl-script PerlHandler Apache::Registry PerlSendHeader On </Location> . . .
        Basically the startup.pl includes which modules I want to include and a couple of additional libraries I wanted to add. Stuff that we wrote for our application. The last part is what you need to pay attention to. If you don't have your environment setup properly then it won't work.

        NOTE: I'm not an expert in the use of Mod_Perl. Never used it until just a few weeks ago. I know that I was able to (finally) get it working just fine. Running the test script provided proof that mod_perl was loaded and running. If you don't see the server software or mod_perl version then it's defintely not loading.

        If it's still not working please post your setup. The section dealing with your /perl location specifically. (hope I didn't confuse you with all this. I'm still learning myself ::grinz::)