Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


Apache2 refuses to run my CGI scripts, telling me it cannot find the file.

Sample log:

[Wed Jul 14 09:22:19 2010] [error] [client] (2)No such file or directory: exec of '/home/pnathan/public_html/' failed
[Wed Jul 14 09:22:19 2010] [error] [client] Premature end of script headers:

Points: is chmod 755. The directory tree it is in is chmod 755. I have another script in the same directory that runs.

LS of

-rwxr-xr-x 1 pnathan pnathan 534 2010-07-14 09:12

My Apache2 config file has this block in it:

   <Directory /home/pnathan/public_html>
      Options Indexes FollowSymLinks MultiViews
      AllowOverride None
      Order allow,deny
      allow from all
      Options +ExecCGI
      AddHandler cgi-script .pl .py

I have no idea what's going on.

share|improve this question
up vote 1 down vote accepted

I'm guessing that the first line of your script has the name of an interpreter that does not exist on your machine.

Now the difference may be as subtle as the fact that if you moved the script from a Windows machine to a UNIX machine that the line ends with a ^M character.

My suggestion is to open the file in 'vi' and see if it says something like "[dos]" at the bottom of your screen. If it does then my guess is correct.

The easiest tool to correct this is dos2unix.

share|improve this answer
For whatever reason your .pl script is aborting. Apache is attempting to run the program but its crashing. It may be the missing interpreter, or some other error in it. Running the program from the command line may be illuminating as well. – Josh Budde Jul 14 '10 at 19:57
Ugh. Line endings were indeed the problem. That's more than a bit idiotic of Apache... Sigh – Paul Nathan Jul 14 '10 at 20:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.