I am working with an Apache2/Redhat5.5 configuration. I am trying to configure (and learn) how to run Perl scripts which is new to me.

In my httpd.conf file I made these changes and/or notice these settings:

DirectoryIndex index.html index.html.var index.cgi index.pl
AddHandler cgi-script .cgi .pl
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all

I have placed this script: http://www.seaglass.com/downloads/file_upload.pl into the /var/www/cgi-bin/ directory.

I then point my browser to myIpAddress/cgi-bin/file_upload.pl and get a "internal server error ... The server encountered an internal error or misconfiguration and was unable to..."

I then check the error log to find this:

[Sun Nov 27 19:59:02 2011] [error] [client ***] (2)No such file or directory: exec of '/var/www/cgi-bin/file_upload.pl' failed
[Sun Nov 27 19:59:02 2011] [error] [client ***] Premature end of script headers: file_upload.pl
[Sun Nov 27 19:59:02 2011] [error] [client ***] File does not exist: /var/www/html/favicon.ico

2 Answers 2


Assuming that you have SELinux enabled, turn on CGI with:

setsebool -P httpd_enable_cgi on

This assumes that the script is uploaded correctly. Perl scripts don't run too well if they are either saved in a DOS format or are uploaded via binary mode via ftp. If you didn't copy the file via ftp (but instead scp or sftp), convert the file with:

dos2unix file_upload.pl
  • As it turns out, the problem had something to do with the text not being in the right format. And, I have been uploading with sftp. For the benefit of others, Something must have happened when I downloaded the script to my windows machine. Simnply copying it over to a new .pl file in Notepad++ (an IDE) seems to have fixed it... the exact same file! Thanks for the tips.
    – Roger
    Nov 27, 2011 at 21:57
  • Sure. BTW, sftp is fine. So most likely it is the file not being in the correct text format.
    – Rilindo
    Nov 27, 2011 at 21:59

This to me sounds like you might not have perl installed on your machine, or that it might be at a path different than /usr/bin/perl. Try typing /usr/bin/perl -v at a command line to comfirm that perl is in fact installed.

It's also possible that you're missing execute permissions on /var/www/cgi-bin/file_upload.pl.

  • Thanks. Regarding the first suggestion: I typed usr/bin/perl -v and received "No such file or directory". However, I should say that I have a SOAP .pl files running in the same cgi-bin directory and that this SOAP file is regularly called by a SOAP client with "myIpAddress/cgi-bin/scriptName.pl" and it has been working fine for a few months. Regarding the second suggestion, I am not sure if this is pertinent, but I did run chmod +x file_upload.pl and the command line made no complaints when I ran it.
    – Roger
    Nov 27, 2011 at 20:42
  • Scratch that first half of my previous reply. I just ran /usr/bin/perl -v and it shows perl v5.8.8 is running. (I made an error by leaving out the first "/".)
    – Roger
    Nov 27, 2011 at 20:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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