-   Linux - General (
-   -   proplems with apache (

robgo777 12-15-2002 02:37 PM

proplems with apache
I have apache- and for some reason it wont let me execute scripts with a .cgi extension. It will only let me execute .pl files as cgi scripts.

I have already edited the httpd.conf file and added the line:

AddHandler cgi-script cgi

But still no luck. Any help would be greatly appreciated.


DavidPhillips 12-15-2002 06:08 PM

what are the permissions set on the files

Syncrm 12-15-2002 07:24 PM

try putting a . in front of cgi:

AddHandler cgi-script .cgi

might also wanna try an "Options ExecCGI" in your httpd.conf file as well.

robgo777 12-15-2002 09:14 PM

Thanks guys so far. Yeah, I have the files set for 0755. If I change the extension to .pl, then they work fine. But if they are .cgi, then it doesn't work

I tried both .cgi and cgi for the AddHandler. And I already have the following tag in my httpd.conf:

<Directory "/var/www/cgi-bin">
AllowOverride None
Options +ExecCGI
Order allow,deny
Allow from all

Any other suggestions??



SlickWilly 12-16-2002 02:35 PM

D'you have an error message you can post?


Or um.. wherever you put your logs..


robgo777 12-17-2002 12:10 PM


The error is:

Premature end of script headers: /var/www/cgi-bin/msingles2/install.cgi



DavidPhillips 12-17-2002 12:15 PM

that sounds like an error in the script

robgo777 12-17-2002 12:39 PM

Okay, I have fixed it. I don't know what I did, but I modified something in my script, it worked, so then I put it back the way it was and it still works! Who knows!

Thanks everyone.


Creep 12-17-2002 12:59 PM

the question is, why did it work as a .pl-file but not as a .cgi-file? does perl handle .cgi in a different way than normal .pl-files?

SlickWilly 12-17-2002 01:06 PM

Urm.. yeah, it's not an apache problem it's a script problem.

I'd hazard a guess that your script was 'copied' over somewhere in binary form instead of ascii, or that it was moved from a windoze machine to a unix machine using shares.

Either will stuff the 'ascii-ness' of your script, and the windoze move will render the script readable, but there are hidden characters at the ends of the lines which will stuff apache's ability to execute it.

There are a couple of work-arounds.
1) copy the text of the script, create new script on unix machine & paste script into vi(m) window.
2) run a dos2ascii converter over your scripts - they remove the extra characters off the end of the line and make it unix proper...

you can find 2) on your system :



There's also the possibilty that you didn't specify the shell as the first line of the script. Something like :


I can't remember if that will give you the above error, mind you.

robgo777 12-21-2002 05:31 PM

I will look into the dos2unix program. How would I use it to check my scripts?



All times are GMT -5. The time now is 09:31 AM.