# mod_perl: scripts are returned as plain text

## sven

Hello!

Running Perl scripts on my Apache worked fine for quite a while until it stopped working some days ago. I merged the new Apache ebuild 2.0.52-r3 but then realised that the mod_perl ebuild has not been switched yet. So I went back to 2.0.52-r2 which was the previous (working) version installed. Now instead of executing Perl scripts Apache only returns them as plain text. I am using the original untouched configuration which worked before! mod_perl is version 1.99.17-r1. "-D PERL" is set in /etc/conf.d/apache2. I've reemerged Apache and mod_perl several times now.

The last bigger change to my system was that I switched to UFT-8 (setting LANG to de_DE.UTF-8). Could that be the problem?

Any idea why Perl scripts are not executed anymore?

Thanks in advance!

----------

## sven

I've changed LANG back to de_DE@euro, executed env-update and rebooted the system but Perl scripts are still returned as plain text  :Sad:  So the problem seems to be related to my accidental merge of apache-2.0.52-r3. But I don't get it... The old Apache has been restored and all files are at their old locations.

http://localhost/perl-status works btw so the Perl module is being loaded...

There are no errors in /var/log/apache2/error_log when I try to execute a Perl script.

----------

## sven

Well I was able to narrow the problem. Scripts from the /perl/ alias which uses the Apache::Registry module to execute the scripts do not work but the same scripts do work under /cgi-perl/ which uses Apache::PerlRun. So the problem seems to be Apache::Registry. I removed all ModPerl related files and folders from /usr/lib/perl5/* and I am now reemerging mod_perl. Hope that helps!

----------

## beanfootage

I have no clue whether this problem was solved, whether you gave up, or whether anyone cares, but I spent the last four hours chasing down this same bug, which seems to be afflicting people across distros and back for several years.  I finally found the problem: the Location tag for /perl/ in 75_mod_perl.conf is malformed.  It still is, as of today.  This is a file included by the ebuild, and is not part of the standard mod_perl release, so it's a gentoo problem.  Here's the fix:

<Location  "^/perl/*.pl>

should be

<Location  /perl/*.pl>

That little "^ is the killer.  Without a ~ after location (as in something like <Location ~ "^/perl/.*">) I think that ^ is getting interpreted literally.  As an aside, the extraneous " doesn't seem to be causing a problem; I guess Apache's smart enough to ignore it.  Anyway, note that immediately below this, there's a tag for /cgi-perl/ that looks almost exactly like the fixed version of the tag for /perl/.  Why was this never caught?  Probably because most people said "um, I'll just make it point to some other directory (like cgi-bin) and now it works so I'm not asking questions."

Also, if you use the default Aliases in that file, you'll need something like:

<Directory "/var/www/localhost/perl">

        AllowOverride All

        Options None

        Order allow,deny

        Allow from all

</Directory>

or you'll get 403: Forbidden messages.

I hope this helps people still fighting with this.

Todd

----------

## slackline

 *beanfootage wrote:*   

>   Here's the fix:
> 
> <Location  "^/perl/*.pl>
> 
> should be
> ...

 

I've been banging my head against the keyboard with this problem myself, I tried closing the double quotes, but that didn't seem to solve it.  The Apache-2.2 documentation says that regular expressions are allowed (i.e. ^ *should* be allowed, although there IS a missing " to close the path) but only if there is a ~ between the Location and the path that is given in quotes (see here).

However, I tried...

    <Location  ~ "^/perl/*.pl">

...which based on the docs and to my mind means "All files in the /perl/ directory that end in .pl" and still get a 403 Forbidden (despite including the permissions discussed below).  Your solution...

    <Location  /perl/*.pl>

...does work however.  Very strange?  Any Apache experts know why one works and the other doesn't?

 *beanfootage wrote:*   

> 
> 
> Also, if you use the default Aliases in that file, you'll need something like:
> 
> <Directory "/var/www/localhost/perl">
> ...

 

I found that you don't necessarily need to define a new <Directory> section, but added the permissions to the <Location /perl/*.pl> section as shown below...

    <Location  /perl/*.pl>

        SetHandler perl-script

        PerlResponseHandler ModPerl::Registry

        Options -Indexes ExecCGI

        PerlSendHeader On

        Order deny,allow

        Deny from all

        Allow from 127.0.0.1

    </Location>

I'm still in the (early) stages of developing and testing so am (hopefully, someone please correct me if I've left myself wide open) restricting access to httpd to the local host at present.

One problem that I can't suss out is that I have to comment out the...

       <IfModule mod_access.c>

      </IfModule>

...clause for perl-status to work.  It appears that a check is being made for an installed module (access), can anyone suggest what this module is? (eix mod_access only returns www-apache/mod_access_snbl and locate mod_access doesn't return anything other than the ebuild for the above)

----------

