Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Getting started with mod_perl

by clinton (Priest)
on Jul 12, 2008 at 11:11 UTC ( #697197=note: print w/ replies, xml ) Need Help??


in reply to Getting started with mod_perl

I suggest you post your segfaulting mod_perl program so that we can see if you're doing anything obviously wrong.

Segfaults with mod_perl are quite rare, in my experience. It's quite possible that you have some bad/mismatched packages. Fortunately, compiling your own apache/mod_perl/libapreq is pretty easy. Below are the steps I use for compiling - adjust as required:

Install prerequisites: autoconf automake bison flex gcc gcc-c++ make db db-devel db-utils zlib zlib-devel openssl openssl-devel ncftp lynx neon neon-devel libevent giflib giflib-devel libjpeg libjpeg-devel libpng libpng-devel libtiff libtiff-devel libxml2 libxml2-devel gzip bzip2 zlib zlib-devel Install CPAN modules: ExtUtils::XSBuilder Parse::RecDescent ====================================================== Get the source files ======================================================== export MPM="prefork" export SUFFIX="_${MPM}_perl_php" export CFLAGS="WHATEVER CFLAGS YOUR PROCESSOR SUPPORTS" cd ~ rm -Rf apache_and_friends mkdir -p apache_and_friends/packages cd apache_and_friends/packages # See http://httpd.apache.org/download.cgi wget http://apache.rediris.es/httpd/httpd-2.2.9.tar.gz # See http://perl.apache.org/download/index.html wget http://perl.apache.org/dist/mod_perl-2.0-current.tar.gz # See http://httpd.apache.org/apreq/download.cgi wget http://apache.rediris.es/httpd/libapreq/libapreq2-2.08.tar.gz cd .. tar -xzf packages/httpd* tar -xzf packages/mod_perl* tar -xzf packages/libapreq* ====================================================== Setup Apache server ======================================================== export APACHE=`echo httpd*` echo "INSTALLING to /opt/$APACHE$SUFFIX" cd $APACHE # This sets up the apache binaries in /opt/httpd....... # with (eg) conf, htdocs etc in /opt/apache/ # adjust the options below for the environment that you want ./configure --prefix=/opt/$APACHE$SUFFIX \ --localstatedir=/opt/apache \ --sysconfdir=/opt/apache/conf \ --datadir=/opt/apache \ --with-mpm=$MPM\ --enable-cache=shared\ --enable-deflate=shared\ --enable-disk-cache=shared\ --enable-file-cache=shared\ --enable-info=shared\ --enable-mem-cache=shared\ --enable-rewrite=shared\ --enable-dav=shared\ --enable-auth-digest\ --enable-ssl=shared\ --enable-expires=shared\ --enable-unique-id=shared\ --enable-usertrack=shared make rm -Rf /opt/$APACHE$SUFFIX make install cd .. ====================================================== Setup mod_perl ======================================================== cd mod_perl-* perl Makefile.PL \ MP_AP_PREFIX=/opt/$APACHE$SUFFIX \ MP_COMPAT_1X=0 make make test && make install && cd .. ====================================================== Setup libapreq ======================================================== cd libapreq* perl Makefile.PL --with-apache2-apxs=/opt/$APACHE$SUFFIX/bin/apxs make && make test && make install cd .. ######################################################## ln -fs /opt/$APACHE$SUFFIX/* /opt/apache ln -sf /opt/apache/bin/apachectl /usr/bin/apachectl ln -sf /opt/apache/bin/apachectl /etc/rc.d/httpd chkconfig httpd on groupadd -r apache useradd -r apache -g apache


Comment on Re: Getting started with mod_perl
Download Code
Re^2: Getting started with mod_perl
by John M. Dlugosz (Monsignor) on Jul 14, 2008 at 06:43 UTC
    The code I tried was the 4 lines from the Synopses: http://search.cpan.org/~joesuf/libapreq2-2.08/glue/perl/lib/Apache2/Request.pm#SYNOPSIS.

    It turn out that it segfaults if you pass new a parameter value of undef. Clearly, that is not a working example, and there is no cross-reference or information on that page about where that value was supposed to have come from in the first place. Sure, I can look up Apache2::RequestRec but that tells me what methods are available, and continues to show a global $r that is assumed to simply exist without showing how you are supposed to declare and obtain it.

      Ah, yes. That's a failure of assumption by the doc authors :), and really Apache2::Request should throw a proper error message instead of segfaulting in that situation. I'd raise a bug against that.

      The reason I say assumption is that, for mod_perl programmers, $r is The One True Way of communicating with mod_perl, and so they have assumed that you know how to get hold of it. For somebody who is new to mod_perl, this is obviously not the case.

      From the emails on the mod_perl mailing list, I assume that you have now sorted the issue out, but for clarification here, to get $r, which is an Apache2::RequestRec object, you would do the following:

      mod_perl 1 had a lot of good docs, a lot of which were written by Stas Bekman while Ticketmaster paid him to work on mod_perl. mod_perl 2 has a lot of good code, but the docs have been written by people who are intimately familiar with the internals. So everything is there, but not as clearly laid out as it could be. Also, everybody has full time jobs... you know how it goes.

      However, they are very receptive to doc (and other) patches, so if you see ways to improve what we have already, feel encouraged to send patches through - they will be warmly welcomed.

      Clint

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://697197]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2014-11-23 01:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (127 votes), past polls