[mod_perl2]: Install error with Makefile.PL - uninitialized value at TestRun.pm

Daniel Boerner <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <CAOCfoG4+OZ+22oUV3-pizOWC9fD=AnqiS1RiQKK3Fo9utTdeDg@mail.gmail.com>
Hi Fred, Hi Todd
I just subscribed to this list and still don't know how to link my message
to your thread from July 10th. Sorry.
I just want to show you my workaround of the same problem: "Install error
with Makefile.PL - uninitialized value at TestRun.pm"

Here my proceedings aiming at a statically mod_perl Apache with Perl 5.14.2
on Debian "squeeze" Linux:

cd ~/src
tar -xvzf perl-5.14.2.tar.gz
cd perl-5.14.2
mkdir "$HOME/perl"
./Configure -des -Dprefix="$HOME/perl" -Dusethreads
make
make test
make install

Making some symlinks... (basically appending a '5' to the name of each
executable in the newly installed $HOME/perl/bin).
su ./perl_version_links.pl /home/dani /usr/local/bin

Some prerequisites:
cpan5
  install CPAN
  reload cpan5
  exit

cpan5
  install YAML
  install LWP
  install CGI
  install Chatbot::Eliza
  install Compress::Zlib
  install Devel::CoreStack
  install Devel::Symdump
  install Digest::MD5
  install IPC::Run3
  exit


And now, making up a statically mod_perl Apache server:

cd ~/src
tar -xvzf httpd-2.2.22.tar.gz
tar -xvzf mod_perl-2.0-current.tar.gz

mkdir "$HOME/apache2"
cd mod_perl-2.0.7/
perl5 Makefile.PL MP_USE_STATIC=1 MP_AP_PREFIX="$HOME/src/httpd-2.2.22"
MP_AP_CONFIGURE="--prefix=$HOME/apache2 --with-mpm=prefork" MP_COMPAT_1X=0

Error:
ERROR from evaluation of
/home/dani/src/mod_perl-2.0.7/Apache-Reload/Makefile.PL: Use of
uninitialized value $v in concatenation (.) or string at
Apache-Test/lib/Apache/TestRun.pm line 1100

Locating line 1100 and adding two print statements just before it:

    my %args = @Apache::TestMM::Argv;
    while (my($k, $v) = each %args) {
print "--> $k\n";
print "---> $v\n";
        $v =~ s/\|/\\|/g;
        $body .= "\n\$Apache::TestConfig::Argv{'$k'} = q|$v|;\n";
    }

Running again:
perl5 Makefile.PL MP_USE_STATIC=1 MP_AP_PREFIX="$HOME/src/httpd-2.2.22"
MP_AP_CONFIGURE="--prefix=$HOME/apache2 --with-mpm=prefork" MP_COMPAT_1X=0

Result:
Configuring Apache/2.2.22 mod_perl/2.0.7 Perl/v5.14.2
--> httpd
---> /home/dani/src/httpd-2.2.22/httpd
--> apxs
ERROR from evaluation of
/home/dani/src/mod_perl-2.0.7/Apache-Reload/Makefile.PL: Use of
uninitialized value $v in concatenation (.) or string at
Apache-Test/lib/Apache/TestRun.pm line 1101.

Ok. As I'm building mod_perl statically, I don't need apxs so I apply the
following workaround: enclose lines 1100 and 1101 in an if-block testing if
$v is defined:

    my %args = @Apache::TestMM::Argv;
    while (my($k, $v) = each %args) {
      if (defined $v) {
        $v =~ s/\|/\\|/g;
        $body .= "\n\$Apache::TestConfig::Argv{'$k'} = q|$v|;\n";
      }
    }

Now, no error and I could proceed with make:

make
make test

...
All tests successful.
Files=242, Tests=2469, 427 wallclock secs ( 4.71 usr  0.94 sys + 372.71
cusr 45.48 csys = 423.84 CPU)
Result: PASS
[warning] server localhost:8529 shutdown
[warning] port 8529 still in use...
done
cd ModPerl-Registry && make test
make[1]: se ingresa al directorio
`/home/dani/src/mod_perl-2.0.7/ModPerl-Registry'
/home/dani/perl/bin/perl -I../blib/arch -I../blib/lib \
        t/TEST  -clean
[warning] setting ulimit to allow core files
ulimit -c unlimited; /home/dani/perl/bin/perl
/home/dani/src/mod_perl-2.0.7/ModPerl-Registry/t/TEST -clean
APACHE_TEST_GROUP= APACHE_TEST_HTTPD= APACHE_TEST_PORT= APACHE_TEST_USER=
APACHE_TEST_APXS= \
        /home/dani/perl/bin/perl -I../blib/arch -I../blib/lib \
        t/TEST  -bugreport -verbose=0
[warning] setting ulimit to allow core files
ulimit -c unlimited; /home/dani/perl/bin/perl
/home/dani/src/mod_perl-2.0.7/ModPerl-Registry/t/TEST -bugreport -verbose=0
/home/dani/src/httpd-2.2.22/httpd  -d
/home/dani/src/mod_perl-2.0.7/ModPerl-Registry/t -f
/home/dani/src/mod_perl-2.0.7/ModPerl-Registry/t/conf/httpd.conf -D APACHE2
-D PERL_USEITHREADS
using Apache/2.2.22 (prefork MPM)

waiting 90 seconds for server to start: ....
waiting 90 seconds for server to start: ok (waited 2 secs)
server localhost:8529 started
t/206.t .............. ok
t/304.t .............. ok
t/404.t .............. ok
t/500.t .............. ok
t/bad_scripts.t ...... ok
t/basic.t ............ ok
t/bin_resp.t ......... ok
t/cgi.t .............. ok
t/closure.t .......... ok
t/dirindex.t ......... ok
t/fatalstobrowser.t .. skipped: fatalsToBrowser known not to work, CGI
version 99.99 or higher is required
t/flush.t ............ skipped: cannot find module 'deflate'
t/ithreads.t ......... ok
t/nph.t .............. ok
t/perlrun_extload.t .. ok
t/prefork.t .......... ok
t/redirect.t ......... ok
t/regex.t ............ ok
t/rewrite_env.t ...... skipped: cannot find module 'mod_rewrite.c'
t/special_blocks.t ... ok
All tests successful.
Files=20, Tests=84, 33 wallclock secs ( 0.39 usr  0.09 sys + 26.39 cusr
3.21 csys = 30.08 CPU)
Result: PASS
[warning] server localhost:8529 shutdown
make[1]: se sale del directorio
`/home/dani/src/mod_perl-2.0.7/ModPerl-Registry'
cd Apache-Reload && make test
make[1]: se ingresa al directorio
`/home/dani/src/mod_perl-2.0.7/Apache-Reload'
/home/dani/perl/bin/perl -I../blib/arch -I../blib/lib \
        t/TEST  -clean
[warning] setting ulimit to allow core files
ulimit -c unlimited; /home/dani/perl/bin/perl
/home/dani/src/mod_perl-2.0.7/Apache-Reload/t/TEST -clean
APACHE_TEST_GROUP= APACHE_TEST_HTTPD= APACHE_TEST_PORT= APACHE_TEST_USER=
APACHE_TEST_APXS= \
        /home/dani/perl/bin/perl -I../blib/arch -I../blib/lib \
        t/TEST  -bugreport -verbose=0
[warning] setting ulimit to allow core files
ulimit -c unlimited; /home/dani/perl/bin/perl
/home/dani/src/mod_perl-2.0.7/Apache-Reload/t/TEST -bugreport -verbose=0
mod_perl 2 was built against Apache sources, we don't know where httpd/apxs
executables are, therefore skipping the test suite execution at
/home/dani/src/mod_perl-2.0.7/Apache-Test/lib/Apache/TestConfig.pm line 371.
make[1]: *** [run_tests] Error 2
make[1]: se sale del directorio
`/home/dani/src/mod_perl-2.0.7/Apache-Reload'
make: *** [run_subtests] Error 2

Again, no apxs needed so I ignore the failure of this last test and proceed
with the install:

make install

Finally, some manual testing (from the mod_perl doc) and everything seems
to work:

Registry Scripts
To enable registry scripts add the following to httpd.conf:

  Alias /perl/ /home/dani/httpd/perl/
  <Location /perl/>
      SetHandler perl-script
      PerlResponseHandler ModPerl::Registry
      PerlOptions +ParseHeaders
      Options +ExecCGI
      Order allow,deny
      Allow from all
  </Location>

and now assuming that we have the following script:

  #!/usr/local/bin/perl5
  print "Content-type: text/plain\n\n";
  print "mod_perl rocks!\n";

saved in /home/dani/httpd/perl/rock.pl. Make the script executable and
readable by everybody:

  % chmod a+rx /home/dani/httpd/perl/rock.pl

Of course the path to the script should be readable by the server too. In
the real world you probably want to have a tighter permissions, but for the
purpose of testing that things are working this is just fine.

Now restart the server and issue a request to
http://localhost/perl/rock.pland you should get the response:

  mod_perl rocks!

If that didn't work check the error_log file.

For more information on the registry scripts refer to the ModPerl::Registry
manpage. (XXX: one day there will a tutorial on registry, should port it
from 1.0's docs).


Handler Modules
Finally check that you can run mod_perl handlers. Let's write a response
handler similar to the registry script from the previous section:

  #file:MyApache2/Rocks.pm
  #----------------------
  package MyApache2::Rocks;

  use strict;
  use warnings;

  use Apache2::RequestRec ();
  use Apache2::RequestIO ();

  use Apache2::Const -compile => qw(OK);

  sub handler {
      my $r = shift;

      $r->content_type('text/plain');
      print "mod_perl 2.0 rocks!\n";

      return Apache2::Const::OK;
  }
  1;

Save the code in the file MyApache2/Rocks.pm, somewhere where mod_perl can
find it. For example let's put it under
/home/dani/httpd/perl/MyApache2/Rocks.pm, and we tell mod_perl that
/home/dani/httpd/perl/ is in @INC, via a startup file which includes just:

  use lib qw(/home/dani/httpd/perl);
  1;

and loaded from httpd.conf:

  PerlRequire /home/dani/httpd/perl/startup.pl

Now we can configure our module in httpd.conf:

  <Location /rocks>
      SetHandler perl-script
      PerlResponseHandler  MyApache2::Rocks
  </Location>

Now restart the server and issue a request to http://localhost/rocks and
you should get the response:

  mod_perl 2.0 rocks!

If that didn't work check the error_log file.


Cheers,
Dani
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.