cgi-bin .pl madness -- please help!

General Discussion of atomic repo and development projects.

Ask for help here with anything else not covered by other forums.
faris
Long Time Forum Regular
Long Time Forum Regular
Posts: 2321
Joined: Thu Dec 09, 2004 11:19 am

cgi-bin .pl madness -- please help!

Unread post by faris »

Back in April I had a problem with running Perl scripts in cgi-bin on sites migrated from Plesk 8.6 to a fresh 10.4.4 install. They were not running at all and giving strange errors in the logs.

At the time, I created a hello world test file called hw.pl for testing.

It turned out that the issue and solution was simple -- the ownership of the cgi-bin directory needed to be user.psaserv and not user.psacln (which is how the migrated sites ended up).

I'm sure I tested quite a bit at the time and everything seemed to be great once the ownership was correctly set.

The problem is that today I've found that no script with a .pl extension in cgi-bin seems to work on any domain. I just get an error 500 Internal Server Error on screen, a "Premature end of script HEADERS" in the error log for the domain (my emphasis on the "headers").

My original hw.pl test file just had a print "hello world\n"; in it. It works fine as a a perl script (e.g. perl /var/www/vhost/domain.tld/cgi-bin/hw.pl displays "hello world" at the command prompt).

I know that when you get header errors it means we need to do something a bit more specific in terms of generating the content of the page.

So I replaced the contents of hw.pl with:

Code: Select all

#!/usr/bin/perl
print "content-type:text/html\n\n";
print "<html>\n";
print "<head>\n";
print "<title>Hello World</title>\n";
print "</head>\n";
print "<body>\n";
print "<b>Hello World!</b><br>\n";
print "</body>\n";
print "</html>\n";

But it made no difference. Still getting the same errors.

However, if I rename the new hw.pl to hw.cgi it works fine. No error. Web page with Hello World in it gets displayed.

An indeed, .cgi files server-wide work fine too, and if I rename them .pl they stop working.

So, what's up with the .pl files??

It is very obvious to me that I'm missing something really simple, fundamental and stupid. But I can't figure it out specifically.

I can see that .pl files get handled in quite a spcific way via the http[stuff].include in /var/www/vhost/conf and I know that somewhere (although I can't find it) there's probably an add-handler for .cgi files in the apache config.

They are obviously being treated differently. Maybe they are supposed to be treated differently? But they worked in 8.6 so I kind of expect them to work the same way in 10.4.4.

Pointers, even if they are along the lines of "You moron...don't you know that...." would be really appreciated!!!!

Additional info below, in case it help.

Thanks,

Faris.


Snippet from /var/www/vhosts/domain.tld/conf/[blah]_httpd.include

Code: Select all

<IfModule mod_perl.c>
    <Files ~ (\.pl$)>
        SetHandler perl-script
        PerlHandler ModPerl::Registry
        Options ExecCGI
        allow from all
        PerlSendHeader On
    </Files>
</IfModule>
mod_perl is loaded via /etc/httpd/conf.d/perl.conf
--------------------------------
<advert>
If you want to rent a UK-based VPS that comes with friendly advice and support from a fellow ART fan, please get in touch.
</advert>
Post Reply