$r not work in mod_perl 2

J

jason.yfho

Dear All,

I installed mod_perl 2 (static mod) in my linux, however, seems the
perl script cannot invoke the mod_perl's function. anyone can give me
some ideaa on the problem? My purpose of using mod_perl is the get the
full header of all HTTP request to Apache. Thank you so much! Below is
the scenario:


System:
- Fedora 3
- Apache 2.2.3
- Perl 5.8.8


I added the following in httpd.conf:
PerlModule Apache2::Registry
<Directory "/usr/local/apache2/htdocs">
.......
Options Indexes FollowSymLinks ExecCGI
PerlHandler Apache2::Registry
PerlSendHeader On
.......
</Directory>


When apache starts, the error_log shows:
[Sat Jan 06 18:43:54 2007] [notice] Apache/2.2.3 (Unix) mod_perl/2.0.3
Perl/v5.8.8 configured -- resuming normal operations


My perl script in "/usr/local/apache2/htdocs/test1.pl":
#!/usr/local/bin/perl5.8.8
use strict;
my $r = shift;
$r->print("It worked!!!\n");


The following error in error_log:
[Sat Jan 06 18:44:32 2007] [error] [client 192.168.1.35] Can't call
method "print" on an undefined value at
/usr/local/apache2/htdocs/test1.pl line 8.


Regards,
Jason
 
B

Brian McCauley

I installed mod_perl 2 (static mod) in my linux, however, seems the
perl script cannot invoke the mod_perl's function. anyone can give me
some ideaa on the problem? My purpose of using mod_perl is the get the
full header of all HTTP request to Apache. Thank you so much! Below is
the scenario:


System:
- Fedora 3
- Apache 2.2.3
- Perl 5.8.8


I added the following in httpd.conf:
PerlModule Apache2::Registry
<Directory "/usr/local/apache2/htdocs">
......
Options Indexes FollowSymLinks ExecCGI
PerlHandler Apache2::Registry
PerlSendHeader On
......
</Directory>

My Apache2+mod_perl2 is a bit rusty but shouldn't there be a
"SetHandler perl-script" in there?

Wasn't Apache2::Registry renamed ModPerl::Registry?
The following error in error_log:
[Sat Jan 06 18:44:32 2007] [error] [client 192.168.1.35] Can't call
method "print" on an undefined value at
/usr/local/apache2/htdocs/test1.pl line 8.

I'd suggest printing out __PACKAGE__. If it says "main" then your
script is being executed via CGI not mod_perl.
 
B

Brian Wakem

Brian said:
My Apache2+mod_perl2 is a bit rusty but shouldn't there be a
"SetHandler perl-script" in there?

Wasn't Apache2::Registry renamed ModPerl::Registry?


I think you are right in both cases as by config file has this:

Alias /cgi-bin /usr/local/apache2/cgi-bin
<Directory /usr/local/apache2/cgi-bin>
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlOptions +ParseHeaders
Options -Indexes +ExecCGI +Includes +FollowSymLinks
AllowOverride Authconfig
Order allow,deny
Allow from all
Deny from [list of banned IPs]
</Directory>
 
J

jason.yfho

Dear Brian,

Thank you for your reply.

When I set "SetHandler perl-script", the script cannot be run and the
browser ask me whether to download the "test1.pl" file.

I found that my Apachectl start error_log:
Apache/2.2.3 (Unix) mod_perl/2.0.3 Perl/v5.8.8 configured

I see the http://perl.apache.org 's installation manual, it's Apache
error_log don't have the "Perl/v5.8.8" configured. Is that "Perl" is
not needed and just "mod_perl" should be used with Apache? i.e. my .pl
script should not be interpreted as by Perl but by mod_perl??

Thank you!

Jason

Brian said:
I installed mod_perl 2 (static mod) in my linux, however, seems the
perl script cannot invoke the mod_perl's function. anyone can give me
some ideaa on the problem? My purpose of using mod_perl is the get the
full header of all HTTP request to Apache. Thank you so much! Below is
the scenario:


System:
- Fedora 3
- Apache 2.2.3
- Perl 5.8.8


I added the following in httpd.conf:
PerlModule Apache2::Registry
<Directory "/usr/local/apache2/htdocs">
......
Options Indexes FollowSymLinks ExecCGI
PerlHandler Apache2::Registry
PerlSendHeader On
......
</Directory>

My Apache2+mod_perl2 is a bit rusty but shouldn't there be a
"SetHandler perl-script" in there?

Wasn't Apache2::Registry renamed ModPerl::Registry?
The following error in error_log:
[Sat Jan 06 18:44:32 2007] [error] [client 192.168.1.35] Can't call
method "print" on an undefined value at
/usr/local/apache2/htdocs/test1.pl line 8.

I'd suggest printing out __PACKAGE__. If it says "main" then your
script is being executed via CGI not mod_perl.
 
B

Brian Wakem

Dear Brian,

Thank you for your reply.

When I set "SetHandler perl-script", the script cannot be run and the
browser ask me whether to download the "test1.pl" file.


Either you do not have that directory configured for execution or, more
likely, you are not printing the correct headers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top