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

Hi, I have installed Apache/2.0.63 (Win32) mod_perl/2.0.3 Perl/v5.8.8 Am trying to run the following code: -------------------------------------------------------
package interface; use CGI::Carp qw(set_die_handler); BEGIN { sub handle_errors { my $msg = shift; print "content-type: text/html\n\n"; print "$msg"; } set_die_handler(\&handle_errors); } use strict; use warnings; use Template; use DBI; eval { ($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1"); # Get the script lo +cation: UNIX / or Windows / ($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1"); # Get the script lo +cation: Windows \ do 'config.do'; do 'templates.do'; do 'shared.do'; do 'database.do'; }; my $config = { INCLUDE_PATH => "$config::templatesAbs", INTERPOLATE => 1, POST_CHOMP => 1, }; print "Content-type:text/html\n\n"; my $template = Template->new($config); my $vars = { images => "$config::imagesUrl", }; my $input = 'welcome.htm'; $template->process($input,$vars) || die $template->error();
---------------------------------------------------------- But apache shuts completely and i get the following error:
[Mon Aug 18 00:13:48 2008] [notice] Parent: child process exited with +status 255 -- Restarting. [Mon Aug 18 00:13:48 2008] [notice] Apache/2.0.63 (Win32) mod_perl/2.0 +.3 Perl/v5.8.8 configured -- resuming normal operations [Mon Aug 18 00:13:48 2008] [notice] Server built: Jan 17 2008 22:58:29 [Mon Aug 18 00:13:48 2008] [crit] (OS 87)The parameter is incorrect. +: Parent: Failed to create the child process. [Mon Aug 18 00:13:48 2008] [crit] (OS 6)The handle is invalid. : mast +er_main: create child process failed. Exiting. [Mon Aug 18 00:13:48 2008] [notice] Parent: Forcing termination of chi +ld process 3385760
I have no clue why this is happening. Please help. Thank you, Anant

Replies are listed 'Best First'.
Re: apache + modperl problem
by jdrago_999 (Hermit) on Aug 17, 2008 at 20:28 UTC
    Start out with a more simple test and work up from there.

    Your problems could be coming from anywhere (even an incompatibility between the version of the DBI module and your mod_perl).

    So start with a handler like this:
    package My::Simple; use strict; use warnings 'all'; use Apache2::RequestRec (); sub handler : method { my ($class, $r) = @_; print "content-type: text/html\n\n"; print "<h1>HELLO WORLD!</h1>"; return 0; } 1;# return true:
    And in your httpd.conf add the following:
    <Perl> use lib '/path/to/your/libs'; </Perl> PerlModule My::Simple <VirtualHost *:80> ServerName www.your-website.com ServerAlias your-website.com SetHandler perl-script PerlResponseHandler My::Simple </VirtualHost>
    Restart your Apache httpd server and access yoursite.com/.

    In your browser, you should see...

    HELLO, WORLD!

    ...and your logs should not contain any errors.

    Once you have confirmed that Perl, Apache and mod_perl are working, you can start debugging your own code, rather than expecting it to be an apache + modperl problem.
      Hi, Thankyou for your prompt reply. I tried modifying my script until the error was not there. Ive realised when i put "use Template" i get the error and apache crashes. When i don't put it, it works fine. How do i fix it cause i need template toolkit for my work. On my server, template toolkit is working fine. Thank you, Anant
        Sometimes the mod_perl.so Apache module doesn't like some other compiled C Perl modules (like Template or parts of DBI).

        Your best bet is to re-install Template from source. If CPAN tells you that "Template is up to date" just download it manually via wget and unzip/install by hand. That should take care of the problem.