Web Hosting Talk







View Full Version : attempt to invoke directory as script ?


jjk2
01-29-2010, 05:22 AM
i get "attempt to invoke directory as script" error in my logs when i try to access /cgi-bin/ on my site.


ScriptAlias /cgi-bin/ /var/www/cgi-bin/
<Directory "/var/www/cgi-bin">
AllowOverride None
AddHandler cgi-script pl cgi
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

what did i miss ?

ubuntu 9.04 apache2

mattle
01-29-2010, 05:27 PM
I think you might want:


AddHandler cgi-script .pl .cgi

jjk2
01-30-2010, 02:16 AM
tried it....still no dice

jjk2
01-30-2010, 03:36 AM
okay works now....but i am getting (8)Exec format error: exec

jjk2
01-30-2010, 06:27 PM
[Fri Jan 29 20:23:28 2010] [error] [client 23.23.23.23] Premature end of script headers: header.php
[Sat Jan 30 10:22:42 2010] [error] [client 23.23.23.23] (8)Exec format error: exec of '/var/www/cgi-bin/header.php' failed

how to fix this ? basically a .cgi script loads header.php which contains javascripts and some php stuff.....

i notice .cgi script runs fine but none of the javascripts and php things work.

mattle
01-31-2010, 12:08 AM
What's the first line of header.php? I can think of a few things that are going on here:

1. If you're going to run PHP in CGI mode, you'll probably need to add ".php" to your AddHandler line
2. The most common cause of "Premature end of script headers" is a bad shebang. The first line of header.php should be something like: #!/usr/local/bin/php.
3. Of course, that implies that you'll need the PHP CLI.
4. header.php will have to be executable

Try this from the command line and put the output here (use a fixed width font, please):


cd /var/www/cgi-bin
ls -l header.php
chmod 755 header.php
head header.php
./header.php