If apache returns ‘Permission denied: exec of <filename> failed’ then you are in two possible situations:

1. ‘filename’ IS A CGI SCRIPT

There could be several reasons for this, for example:

– Misconfigured <Directory> directive

In particular verify that ExecCGI and AddHandler are properly configured. For example:

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

– Permission problem in the specified directory and/or file

Make sure the directory can be read from the user that runs the apache processes and that the script has execution permissions. If in linux, verify that SELinux is not preventing the access and/or execution of the script.

2. ‘filename’ IS NOT A CGI SCRIPT

If you have this error when you are trying to access normal html pages, then look in the config file for the directive:

SetHandler cgi-script

The above directive force everything to be considered a CGI script; to fix this remove the directive or (if you need to execute CGI scripts) replace it with something like the following:

AddHandler cgi-script .cgi .pl