FAQ
I am having a lot of trouble with mod_perl APIs.

The short of it is that when I say:

use Apache2::Directive ();
my $tree = Apache2::Directive::conftree();
my $documentroot = $tree->lookup('DocumentRoot');
warn "\$documentroot '$documentroot'";

I get:
[Wed May 14 12:13:43 2014] -e: Use of uninitialized value $documentroot
in concatenation (.) or string at /home/worik/Worik.org/cgi/track line 11.
[Wed May 14 12:13:43 2014] -e: $documentroot '' at
/home/worik/Worik.org/cgi/track line 11.

in the logs.

I copied the code from
https://perl.apache.org/docs/2.0/api/Apache2/Directive.html

The longer of it is:

In the past (15 years ago) I installed mod_perl and forgot about it. I
set up my perl cgi script handler to be mod_perl in httpd.conf, and the
only real effect it had on my development cycle was I often had to
restart Apache to get it to notice I had changed a script.

These days I am more ambitious and am returning to Web programming after
a long break.

I expect mod_perl to still be useful to cut the overhead of starting
Perl. I expect a high throughput this time around, each request will be
worth very little to me so I want lots and lots of requests. SO far so
good.

I have set up my server:

         ## mod_perl2 configuration
         Alias /cgi/ /home/worik/Worik.org/cgi/
         PerlModule ModPerl::Registry
         ## PerlModule Apache::Registry
         PerlSwitches -T
         ErrorLog ${APACHE_LOG_DIR}/Worik.error.log
         <Location /cgi/>
            SetHandler perl-script
            PerlResponseHandler ModPerl::Registry
            PerlOptions +ParseHeaders
            Options +ExecCGI
            Order allow,deny
            Allow from all
         </Location>

Now I would like to use the API. In the first instance I want to find
what the directory is I am running in. So I want to say:

use Apache2::Directive ();
my $tree = Apache2::Directive::conftree();
my $pwd = $tree->lookup("cgi");

But that fails just like the example at the start of this email.

Also my errors are coming out in the wrong log. When I say warn("foo")
I expect it to come out in the file specified by the ErrorLog directive
but it comes as:

[Wed May 14 12:22:53 2014] -e: foo at /home/worik/Worik.org/cgi/track
line 12.

in /var/log/apache2/error.log which is not what I specified.

I am at a loss. Is the documentation up to date? Is mod_perl still
being used out there?

cheers
Worik

--
The only true evil is turning people into things....
                                          Granny Weatherwax
        worik.stanton@gmail.com 021-1680650, (03) 4821804
                           Aotearoa (New Zealand)

Search Discussions

  • Perrin Harkins at May 15, 2014 at 4:07 am
    Hi Worik,

    Your ErrorLog question isn't really a mod_perl issue, but I'd suggest
    you check for warnings at startup. You may not have APACHE_LOG_DIR
    defined, etc.

    I don't use Apache2::Directive, so I can't vouch for it. I prefer
    simpler things like PerlSetVar. There is an automated test for this
    though:
    http://cpansearch.perl.org/src/PHRED/mod_perl-2.0.8/t/response/TestApache/conftree.pm

    I'd suggest doing some more basic debugging, e.g.

       use Data::Dumper;
       print Dumper $tree->as_hash;

    - Perrin
    On Tue, May 13, 2014 at 8:24 PM, Worik Stanton wrote:
    I am having a lot of trouble with mod_perl APIs.

    The short of it is that when I say:

    use Apache2::Directive ();
    my $tree = Apache2::Directive::conftree();
    my $documentroot = $tree->lookup('DocumentRoot');
    warn "\$documentroot '$documentroot'";

    I get:
    [Wed May 14 12:13:43 2014] -e: Use of uninitialized value $documentroot
    in concatenation (.) or string at /home/worik/Worik.org/cgi/track line 11.
    [Wed May 14 12:13:43 2014] -e: $documentroot '' at
    /home/worik/Worik.org/cgi/track line 11.

    in the logs.

    I copied the code from
    https://perl.apache.org/docs/2.0/api/Apache2/Directive.html

    The longer of it is:

    In the past (15 years ago) I installed mod_perl and forgot about it. I
    set up my perl cgi script handler to be mod_perl in httpd.conf, and the
    only real effect it had on my development cycle was I often had to
    restart Apache to get it to notice I had changed a script.

    These days I am more ambitious and am returning to Web programming after
    a long break.

    I expect mod_perl to still be useful to cut the overhead of starting
    Perl. I expect a high throughput this time around, each request will be
    worth very little to me so I want lots and lots of requests. SO far so
    good.

    I have set up my server:

    ## mod_perl2 configuration
    Alias /cgi/ /home/worik/Worik.org/cgi/
    PerlModule ModPerl::Registry
    ## PerlModule Apache::Registry
    PerlSwitches -T
    ErrorLog ${APACHE_LOG_DIR}/Worik.error.log
    <Location /cgi/>
    SetHandler perl-script
    PerlResponseHandler ModPerl::Registry
    PerlOptions +ParseHeaders
    Options +ExecCGI
    Order allow,deny
    Allow from all
    </Location>

    Now I would like to use the API. In the first instance I want to find
    what the directory is I am running in. So I want to say:

    use Apache2::Directive ();
    my $tree = Apache2::Directive::conftree();
    my $pwd = $tree->lookup("cgi");

    But that fails just like the example at the start of this email.

    Also my errors are coming out in the wrong log. When I say warn("foo")
    I expect it to come out in the file specified by the ErrorLog directive
    but it comes as:

    [Wed May 14 12:22:53 2014] -e: foo at /home/worik/Worik.org/cgi/track
    line 12.

    in /var/log/apache2/error.log which is not what I specified.

    I am at a loss. Is the documentation up to date? Is mod_perl still
    being used out there?

    cheers
    Worik

    --
    The only true evil is turning people into things....
    Granny Weatherwax
    worik.stanton@gmail.com 021-1680650, (03) 4821804
    Aotearoa (New Zealand)
  • Worik Stanton at May 15, 2014 at 12:52 am

    On 15/05/14 05:16, Perrin Harkins wrote:
    Hi Worik,

    Your ErrorLog question isn't really a mod_perl issue, but I'd suggest
    you check for warnings at startup. You may not have APACHE_LOG_DIR
    defined, etc.
    The ErrorLog issue only happens under mod_perl. Given that all logs
    were in the appropriate directory but I went and checked and it is set
    appropriately in apache2/envvars. If you look at the snippet of my
    configuration file you will see I set the error log just before setting
    up mod_perl.
    I don't use Apache2::Directive, so I can't vouch for it. I prefer
    simpler things like PerlSetVar. There is an automated test for this
    though:
    http://cpansearch.perl.org/src/PHRED/mod_perl-2.0.8/t/response/TestApache/conftree.pm
    Thank you that is useful. I will look into that. I have gotten that
    file. Is there some documentation to go with it?
    I'd suggest doing some more basic debugging, e.g.

    use Data::Dumper;
    print Dumper $tree->as_hash;
    Thank you. That is helpful too.

    cheers
    Worik
    - Perrin
    On Tue, May 13, 2014 at 8:24 PM, Worik Stanton wrote:
    I am having a lot of trouble with mod_perl APIs.

    The short of it is that when I say:

    use Apache2::Directive ();
    my $tree = Apache2::Directive::conftree();
    my $documentroot = $tree->lookup('DocumentRoot');
    warn "\$documentroot '$documentroot'";

    I get:
    [Wed May 14 12:13:43 2014] -e: Use of uninitialized value $documentroot
    in concatenation (.) or string at /home/worik/Worik.org/cgi/track line 11.
    [Wed May 14 12:13:43 2014] -e: $documentroot '' at
    /home/worik/Worik.org/cgi/track line 11.

    in the logs.

    I copied the code from
    https://perl.apache.org/docs/2.0/api/Apache2/Directive.html

    The longer of it is:

    In the past (15 years ago) I installed mod_perl and forgot about it. I
    set up my perl cgi script handler to be mod_perl in httpd.conf, and the
    only real effect it had on my development cycle was I often had to
    restart Apache to get it to notice I had changed a script.

    These days I am more ambitious and am returning to Web programming after
    a long break.

    I expect mod_perl to still be useful to cut the overhead of starting
    Perl. I expect a high throughput this time around, each request will be
    worth very little to me so I want lots and lots of requests. SO far so
    good.

    I have set up my server:

    ## mod_perl2 configuration
    Alias /cgi/ /home/worik/Worik.org/cgi/
    PerlModule ModPerl::Registry
    ## PerlModule Apache::Registry
    PerlSwitches -T
    ErrorLog ${APACHE_LOG_DIR}/Worik.error.log
    <Location /cgi/>
    SetHandler perl-script
    PerlResponseHandler ModPerl::Registry
    PerlOptions +ParseHeaders
    Options +ExecCGI
    Order allow,deny
    Allow from all
    </Location>

    Now I would like to use the API. In the first instance I want to find
    what the directory is I am running in. So I want to say:

    use Apache2::Directive ();
    my $tree = Apache2::Directive::conftree();
    my $pwd = $tree->lookup("cgi");

    But that fails just like the example at the start of this email.

    Also my errors are coming out in the wrong log. When I say warn("foo")
    I expect it to come out in the file specified by the ErrorLog directive
    but it comes as:

    [Wed May 14 12:22:53 2014] -e: foo at /home/worik/Worik.org/cgi/track
    line 12.

    in /var/log/apache2/error.log which is not what I specified.

    I am at a loss. Is the documentation up to date? Is mod_perl still
    being used out there?

    cheers
    Worik

    --
    The only true evil is turning people into things....
    Granny Weatherwax
    worik.stanton@gmail.com 021-1680650, (03) 4821804
    Aotearoa (New Zealand)

    --
    The only true evil is turning people into things....
                                              Granny Weatherwax
            worik.stanton@gmail.com 021-1680650, (03) 4821804
                               Aotearoa (New Zealand)
  • Worik Stanton at May 15, 2014 at 1:58 am
    On another matter...
    On 15/05/14 05:16, Perrin Harkins wrote:
    simpler things like PerlSetVar. There is an automated test for this
    though:
    http://cpansearch.perl.org/src/PHRED/mod_perl-2.0.8/t/response/TestApache/conftree.pm
    I have not used this testing frame work before (other than watch tests
    go by during the build process).

    I looked up http://perl.apache.org/docs/general/testing/testing.html but
    there does not seem to be a tutorial to get started. Where is the
    documentation that shows how to arrange the files and run these tests?

    I tried creating a directory t/ and t/TestApache and put conftree.pm
    into TestApache and created a file contree.pl which used
    TestApache::conftree

    (I had to add a "1;" to the last line of conftree.pm which was an
    indication I was on the wrong track).

    I then called TestApache::conftree->new(@ARGV)->run();

    Anyway clearly I am doing the wrong thing, no matter how natural it
    seems and I need some help to get on the right track

    cheers
    Worik

    --
    The only true evil is turning people into things....
                                              Granny Weatherwax
            worik.stanton@gmail.com 021-1680650, (03) 4821804
                               Aotearoa (New Zealand)
  • John Dunlap at May 16, 2014 at 6:59 pm
    If I may ask a potentially stupid question, what are you attempting to do
    which necessitates the use of Apache2::Directive?

    On Wed, May 14, 2014 at 5:01 PM, Worik Stanton wrote:

    On another matter...
    On 15/05/14 05:16, Perrin Harkins wrote:
    simpler things like PerlSetVar. There is an automated test for this
    though:
    http://cpansearch.perl.org/src/PHRED/mod_perl-2.0.8/t/response/TestApache/conftree.pm

    I have not used this testing frame work before (other than watch tests
    go by during the build process).

    I looked up http://perl.apache.org/docs/general/testing/testing.html but
    there does not seem to be a tutorial to get started. Where is the
    documentation that shows how to arrange the files and run these tests?

    I tried creating a directory t/ and t/TestApache and put conftree.pm
    into TestApache and created a file contree.pl which used
    TestApache::conftree

    (I had to add a "1;" to the last line of conftree.pm which was an
    indication I was on the wrong track).

    I then called TestApache::conftree->new(@ARGV)->run();

    Anyway clearly I am doing the wrong thing, no matter how natural it
    seems and I need some help to get on the right track

    cheers
    Worik

    --
    The only true evil is turning people into things....
    Granny Weatherwax
    worik.stanton@gmail.com 021-1680650, (03) 4821804
    Aotearoa (New Zealand)
  • Worik Stanton at May 16, 2014 at 10:51 pm

    On 16/05/14 08:24, John Dunlap wrote:
    If I may ask a potentially stupid question, what are you attempting to do
    which necessitates the use of Apache2::Directive?
    I am randomly thrashing around trying to get started with the mod_perl
    API. More accurately I was. I have my bearings now and am making some
    progress.

    I have used the API today to get document_root (thank-you
    john@lariat.co) and to filter by IP.

    cheers
    Worik
    On Wed, May 14, 2014 at 5:01 PM, Worik Stanton wrote:

    On another matter...
    On 15/05/14 05:16, Perrin Harkins wrote:
    simpler things like PerlSetVar. There is an automated test for this
    though:
    http://cpansearch.perl.org/src/PHRED/mod_perl-2.0.8/t/response/TestApache/conftree.pm

    I have not used this testing frame work before (other than watch tests
    go by during the build process).

    I looked up http://perl.apache.org/docs/general/testing/testing.html but
    there does not seem to be a tutorial to get started. Where is the
    documentation that shows how to arrange the files and run these tests?

    I tried creating a directory t/ and t/TestApache and put conftree.pm
    into TestApache and created a file contree.pl which used
    TestApache::conftree

    (I had to add a "1;" to the last line of conftree.pm which was an
    indication I was on the wrong track).

    I then called TestApache::conftree->new(@ARGV)->run();

    Anyway clearly I am doing the wrong thing, no matter how natural it
    seems and I need some help to get on the right track

    cheers
    Worik

    --
    The only true evil is turning people into things....
    Granny Weatherwax
    worik.stanton@gmail.com 021-1680650, (03) 4821804
    Aotearoa (New Zealand)

    --
    The only true evil is turning people into things....
                                              Granny Weatherwax
            worik.stanton@gmail.com 021-1680650, (03) 4821804
                               Aotearoa (New Zealand)
  • Lars Dɪᴇᴄᴋᴏᴡ 迪拉斯 at May 16, 2014 at 10:38 pm

    I looked up http://perl.apache.org/docs/general/testing/testing.html
    This is for testing applications written on top of mod_perl2.
    Where is the
    documentation that shows how to arrange the files and run these tests?
    In <http://p3rl.org/ExtUtils::MakeMaker>. Generate the test files as
    described in the mod_perl2 INSTALL file, then you can also run a test
    file isolated:

         make test TEST_VERBOSE=1 TEST_FILES=t/apache/conftree.t
  • John Dunlap at May 16, 2014 at 1:42 pm
    Why can't you just do this?

    sub handler {
         my ($apache) = @_;
         my $documentroot = $apache->document_root;
    }



    On Tue, May 13, 2014 at 8:24 PM, Worik Stanton wrote:

    I am having a lot of trouble with mod_perl APIs.

    The short of it is that when I say:

    use Apache2::Directive ();
    my $tree = Apache2::Directive::conftree();
    my $documentroot = $tree->lookup('DocumentRoot');
    warn "\$documentroot '$documentroot'";

    I get:
    [Wed May 14 12:13:43 2014] -e: Use of uninitialized value $documentroot
    in concatenation (.) or string at /home/worik/Worik.org/cgi/track line 11.
    [Wed May 14 12:13:43 2014] -e: $documentroot '' at
    /home/worik/Worik.org/cgi/track line 11.

    in the logs.

    I copied the code from
    https://perl.apache.org/docs/2.0/api/Apache2/Directive.html

    The longer of it is:

    In the past (15 years ago) I installed mod_perl and forgot about it. I
    set up my perl cgi script handler to be mod_perl in httpd.conf, and the
    only real effect it had on my development cycle was I often had to
    restart Apache to get it to notice I had changed a script.

    These days I am more ambitious and am returning to Web programming after
    a long break.

    I expect mod_perl to still be useful to cut the overhead of starting
    Perl. I expect a high throughput this time around, each request will be
    worth very little to me so I want lots and lots of requests. SO far so
    good.

    I have set up my server:

    ## mod_perl2 configuration
    Alias /cgi/ /home/worik/Worik.org/cgi/
    PerlModule ModPerl::Registry
    ## PerlModule Apache::Registry
    PerlSwitches -T
    ErrorLog ${APACHE_LOG_DIR}/Worik.error.log
    <Location /cgi/>
    SetHandler perl-script
    PerlResponseHandler ModPerl::Registry
    PerlOptions +ParseHeaders
    Options +ExecCGI
    Order allow,deny
    Allow from all
    </Location>

    Now I would like to use the API. In the first instance I want to find
    what the directory is I am running in. So I want to say:

    use Apache2::Directive ();
    my $tree = Apache2::Directive::conftree();
    my $pwd = $tree->lookup("cgi");

    But that fails just like the example at the start of this email.

    Also my errors are coming out in the wrong log. When I say warn("foo")
    I expect it to come out in the file specified by the ErrorLog directive
    but it comes as:

    [Wed May 14 12:22:53 2014] -e: foo at /home/worik/Worik.org/cgi/track
    line 12.

    in /var/log/apache2/error.log which is not what I specified.

    I am at a loss. Is the documentation up to date? Is mod_perl still
    being used out there?

    cheers
    Worik

    --
    The only true evil is turning people into things....
    Granny Weatherwax
    worik.stanton@gmail.com 021-1680650, (03) 4821804
    Aotearoa (New Zealand)

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupmodperl @
categoriesmodperl, perl
postedMay 14, '14 at 1:27a
activeMay 16, '14 at 10:51p
posts8
users4
websiteperl.apache.org

People

Translate

site design / logo © 2018 Grokbase