Running CGI With Perl under Apache Permission Problem
- by neversaint
I have the following entry under apache2.conf in my Debian box.
AddHandler cgi-script .cgi .pl
Options +ExecCGI
ScriptAlias /mychosendir/cgi-bin/ /var/www/mychosendir/cgi-bin/
<Directory /var/www/mychosendir/cgi-bin>
Options +ExecCGI -Indexes
allow from all
</Directory>
Then I have a perl cgi script stored under these directories and permissions:
nvs@somename:/var/www/mychosendir$ ls -lhR
.:
total 12K
drwxr-xr-x 2 nvs nvs 4.0K 2010-04-21 13:42 cgi-bin
./cgi-bin:
total 4.0K
-rwxr-xr-x 1 nvs nvs 90 2010-04-21 13:40 test.cgi
However when I tried to access it in the web browser:
http://myhost.com/mychosendir/cgi-bin/test.cgi
They gave me this error:
[Wed Apr 21 15:26:09 2010] [error] [client 150.82.219.158] (8)Exec format error: exec of '/var/www/mychosendir/cgi-bin/test.cgi' failed
[Wed Apr 21 15:26:09 2010] [error] [client 150.82.219.158] Premature end of script headers: test.cgi
What's wrong with it?
Update:
I also have the following entry in my apache2.conf:
<Files ~ "^\.ht">
Order allow,deny
Deny from all
</Files>
And the content of test.cgi is this:
#!/usr/bin/perl -wT
print "Content-type: text/html\n\n";
print "Hello, world!\n";