You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Tofu Optimist <to...@yahoo.com> on 2003/08/01 13:02:20 UTC

handler help

Hi.

I need some help with handlers.

I'm a linux newbie.  I freshly installed RH 9.
I built perl 5.8.0 from source.

As non-root, I downloaded source for
Apache 1.3.28 and mod_perl 1.28
and built them, using the instructions here

http://perl.apache.org/docs/1.0/guide/install.html#A_Summary_of_a_Basic_mod_perl_Installation

I've also been using Stas' book, Practical Mod Perl,
and the mod_perl developer's cookbook.

The only change I made to the
A_Summary_of_a_Basic_mod_perl_Installation
was using SU to root for the make install for
mod_perl.

The resulting Apache runs fine.

The resuling mod_perl runs cgi-scripts fine.

At times I'm running two servers on the same box, one
listening
to port 80 and one listening to port 8080.
I turned off the ssl piece of both servers, as they
were colliding
on port (I think) 443.  I'm not sure if this 2 server
issue
or the turning ssl is relevant to my problem.

Now I'm trying to write my first mod_perl handler:

PerlModule Apache::HandlerTest
<Location /handlertest>
    SetHandler perl-script
    PerlHandler Apache::HandlerTest
 </Location>


package Apache::HandlerTest;
  # File is called Apache/HandlerTest.pm
  # Path:
/usr/lib/perl5/site_perl/5.8.0/Apache/HandlerTest.pm
  
  sub handler {
      my $r = shift; # Apache session object
      $r->content_type('text/html');
      $r->send_http_header;
      $r->print( "Hello, world." );
  }
  

It dies with an 

Internal Server Error
The server encountered an internal error or
misconfiguration and was unable to complete your
request

Here's the end of the log


[Thu Jul 31 18:34:08 2003] [error] [client
192.168.1.2] Can't locate object method "content_type"
via package "Apache::RequestRec" at
/usr/lib/perl5/site_perl/5.8.0/Apache/HandlerTest.pm
line 6.!
[Thu Jul 31 18:34:08 2003] [error] [client
192.168.1.2] File does not exist: /var/www/error

As the problem seesm related to finding things, I
tried making
the handler simpler by using no functions

sub handler {
 print "HTTP/1.0 200 OK\n";
 print "Content-Type: text/html\n\n";
 print "<html><body>Hello</body></html>";
 return 200;      
}

This didn't work either --

[Thu Jul 31 18:42:57 2003] [error] [client
192.168.1.2] Can't locate object method "PRINT" via
package "Apache::RequestRec" at
/usr/lib/perl5/site_perl/5.8.0/Apache/HandlerTest.pm
line 13.!
[Thu Jul 31 18:42:57 2003] [error] [client
192.168.1.2] File does not exist: /var/www/error

I guess the print is really a call to $r->print()
(Practical Mod_perl p 238).

This newcoming to mod-perl seeks any help on next
steps.

RKG

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

Re: handler help

Posted by Perrin Harkins <pe...@elem.com>.
On Fri, 2003-08-01 at 07:02, Tofu Optimist wrote:
> I'm a linux newbie.  I freshly installed RH 9.
> I built perl 5.8.0 from source.

Go and change your locale from UTF8 to en_US or C.  See this for why:
http://archive.develooper.com/perl5-porters@perl.org/msg97360.html

> As non-root, I downloaded source for
> Apache 1.3.28 and mod_perl 1.28
> and built them, using the instructions here
> 
> http://perl.apache.org/docs/1.0/guide/install.html#A_Summary_of_a_Basic_mod_perl_Installation

Okay...

> [Thu Jul 31 18:34:08 2003] [error] [client
> 192.168.1.2] Can't locate object method "content_type"
> via package "Apache::RequestRec" at
> /usr/lib/perl5/site_perl/5.8.0/Apache/HandlerTest.pm
> line 6.!

That's mod_perl 2.  (There is Apache::RequestRec in mod_perl 1.)  You
must have an older one on your box and you are trying to run this
handler with it.  Figure out where you installed mod_perl 1 and use that
instead.

- Perrin