Problem getting started
am 12.07.2008 08:21:15 von l3hc4oo02
I'm trying to use mod_perl on Debian Etch. I was looking at "practical mod_perl" book, but it appears that much has changed in mod_perl 2.0 so the second example doesn't work at all.
The first example, which is just two print statements to give a minimal header and content text, is invoked so I know the code is installed and the Apache configuration files are set up.
But the code from the Synopses of the Apache2::Request module documentation causes a segfault on the second line. The 'use' is OK, but the 'new' shows in the apache logs that there was a segfault.
How do I begin to find out what the real error is? Is there something more that needs to be done with Debian installing from the apt? Could someone post a trivial example that ought to work?
--John
Re: Problem getting started
am 12.07.2008 14:58:27 von Adam Prime
John M. Dlugosz wrote:
> I'm trying to use mod_perl on Debian Etch. I was looking at "practical mod_perl" book, but it appears that much has changed in mod_perl 2.0 so the second example doesn't work at all.
>
> The first example, which is just two print statements to give a minimal header and content text, is invoked so I know the code is installed and the Apache configuration files are set up.
>
> But the code from the Synopses of the Apache2::Request module documentation causes a segfault on the second line. The 'use' is OK, but the 'new' shows in the apache logs that there was a segfault.
>
> How do I begin to find out what the real error is? Is there something more that needs to be done with Debian installing from the apt? Could someone post a trivial example that ought to work?
>
> --John
It looks like the examples from practical mod_perl are from before the
API was changed to use Apache2:: instead of Apache::. So for all those
examples you'd need to s/Apache::/Apache2::/g. If you could provide a
link to the specific example you're having trouble with that might help.
The whole book is online at http://modperlbook.org/ if you weren't
already aware.
For the Apache2::Request problem you're running:
use Apache2::Request;
$req = Apache2::Request->new($r);
@foo = $req->param("foo");
$bar = $req->args("bar");
and getting a segfault on new?
Are you running this as a handler, or through one of the CGI emulation
layers (ModPerl::PerlRun, or ModPerl::Registry for example). you do
also have
my $r = shift;
somewhere above that (and ideally use strict; as well) right?
I personally normally install mp and libapreq from source, so i'm not
familiar with how one would install/configure them using debian.
Adam
Re: Problem getting started
am 12.07.2008 16:50:06 von Raymond Wan
Hi John,
Unfortunately, I'm still muddy with modperl to help you even though I'm
on Debian Etch. I have it working and can tell you what I have
installed...but I can't help you with modperl specifics as I'll probably
end up teaching the wrong thing.
To answer Adam's question:
Adam Prime wrote:
> John M. Dlugosz wrote:
>> I'm trying to use mod_perl on Debian Etch. I was looking at
>> "practical mod_perl" book, but it appears that much has changed in
>> mod_perl 2.0 so the second example doesn't work at all.
>>
> I personally normally install mp and libapreq from source, so i'm not
> familiar with how one would install/configure them using debian.
aptitude install libapreq2
as root (or sudo). Or just install everything related if you are not sure:
aptitude install libapache2-mod-apreq2 libapreq2 libapreq2-dev libapreq2-doc
(I have all of them installed.)
Of course, apt-get works too, if you prefer that. I don't remember
doing more configuration. There's a symlink from
/etc/apache2/mods-enabled/apreq.load to
/etc/apache2/mods-available/apreq.load
Sorry, can't think of anything else tricky that I did. I hope this is
enough.
Ray
Re: Problem getting started
am 13.07.2008 05:24:57 von Adam Prime
Please include the list on replies, so the archives are complete.
Quoting "John M. Dlugosz" :
> Adam Prime adam.prime-at-utoronto.ca |mod_perl mailing list| wrote:
>> For the Apache2::Request problem you're running:
>>
>> use Apache2::Request;
>> $req =3D Apache2::Request->new($r);
>> @foo =3D $req->param("foo");
>> $bar =3D $req->args("bar");
>>
>> and getting a segfault on new?
>
> If I reduce it down to the first two lines only, I get the segfault.
> If I reduce it to the first line only, I don't.
>
>
>> Are you running this as a handler, or through one of the CGI =20
>> emulation layers (ModPerl::PerlRun, or ModPerl::Registry for =20
>> example). you do
>
> ModPerl::Registry.
>
> In my apache2.conf file:
>
> =09PerlModule ModPerl::Registry
>
> =09
> =09 SetHandler perl-script
> =09 PerlHandler ModPerl::Registry
> =09 Options +ExecCGI
> =09 PerlSendHeader On
> =09 Allow from all
> =09
>
> Hmm, is there a way to find out whether these settings are applying to
> the directory I think it is? /modperl/ should be applied to each
> DocumentRoot, right?
>
correct.
>> also have
>>
>> my $r =3D shift;
>>
>> somewhere above that (and ideally use strict; as well) right?
>
> No, just what it shows in the example.
This is your problem. Apparently if you call Apache2::Request->new
with an undefined object, it segfaults.
i ran this:
use Apache2::Request;
my $req =3D Apache2::Request->new($r);
print qq[Content-type: text/html\n\n];
print q[hi];
through registry, and saw
[Sat Jul 12 22:58:58 2008] [notice] child pid 5703 exit signal
Segmentation fault (11)
If you change that to
use Apache2::Request;
my $r =3D shift;
my $req =3D Apache2::Request->new($r);
print qq[Content-type: text/html\n\n];
print q[hi];
it should work. Unfortunately, it looks like the documentation for
ModPerl::Registry is kind of lacking on perl.apache.org, but what is
there is at
http://perl.apache.org/docs/2.0/api/ModPerl/Registry.html
Adam
Re: Problem getting started
am 13.07.2008 07:21:46 von l3hc4oo02
> This is your problem. Apparently if you call Apache2::Request->new
> with an undefined object, it segfaults.
>
> i ran this:
>
> use Apache2::Request;
> my $req = Apache2::Request->new($r);
> print qq[Content-type: text/html\n\n];
> print q[hi];
>
> through registry, and saw
>
> [Sat Jul 12 22:58:58 2008] [notice] child pid 5703 exit signal
> Segmentation fault (11)
>
> If you change that to
>
> use Apache2::Request;
> my $r = shift;
> my $req = Apache2::Request->new($r);
> print qq[Content-type: text/html\n\n];
> print q[hi];
>
> it should work. Unfortunately, it looks like the documentation for
> ModPerl::Registry is kind of lacking on perl.apache.org, but what is
> there is at
> http://perl.apache.org/docs/2.0/api/ModPerl/Registry.html
>
> Adam
>
OK, when I defined $r as you did, it worked. For documentation, I was
looking at here:
I see you are just printing to standard output, like a CGI script. In
the book, it used
$r->send_http_header('text/plain');
$r->print("mod_perl rules!\n");
but there are no such methods on $r here in 2.0.
What, prey tell, is the equivalent object?
Is there =any= way to get started, like a simple (but working!) program
I could look at?
--John
Re: Problem getting started
am 13.07.2008 07:34:58 von Raymond Wan
Hi John,
John M. Dlugosz wrote:
> OK, when I defined $r as you did, it worked. For documentation, I was
> looking at here:
>
>
>
> I see you are just printing to standard output, like a CGI script. In
> the book, it used
>
> $r->send_http_header('text/plain');
> $r->print("mod_perl rules!\n");
>
> but there are no such methods on $r here in 2.0.
>
> What, prey tell, is the equivalent object?
> Is there =any= way to get started, like a simple (but working!)
> program I could look at?
When I was starting with modperl2, I had similar problems to you. I'm
more of a book-person, and many of the books (such as the O'Reilly ones)
have not been re-released for modperl2. While there is a lot of
information on the web, it isn't as easy sifting through it all.
As for your question, the $r object is (I believe :-) ) the RequestRec
object:
http://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html
and instead of send_http_header, you would use content_type. As
mentioned here which describes porting mod_perl 1.0 to mod_perl 2.0:
http://perl.apache.org/docs/2.0/user/porting/compat.html#C__ r_E_gt_send_http_header_
You may need to use these two documents (at least) in conjunction with
the book you are reading to make any sense of it. Hope this helps!
Ray
Re: Problem getting started
am 17.07.2008 23:45:06 von Perrin Harkins
On Sun, Jul 13, 2008 at 1:21 AM, John M. Dlugosz
wrote:
> OK, when I defined $r as you did, it worked. For documentation, I was
> looking at here:
>
Hi John,
That SYNOPSIS is more like a set of possible calls to
Apache2::Request, not a literal series of lines. You do need to get
$r (an Apache2::RequestRec object) first.
> I see you are just printing to standard output, like a CGI script.
When using ModPerl::Registry, you can just print to STDOUT.
> In the book, it used
>
> $r->send_http_header('text/plain');
> $r->print("mod_perl rules!\n");
>
> but there are no such methods on $r here in 2.0.
>
> What, prey tell, is the equivalent object?
That's Apache2::RequestRec.
> Is there =any= way to get started, like a simple (but working!) program I
> could look at?
There are two places you should look for MP2 docs. The first is the
mod_perl site, which has all the API docs and many examples. If you
want a book, the only one you should use for MP2 at this point is
"mod_perl2 User's Guide": http://modperl2book.org/
- Perrin