Options ExecCGI is off in this directory: /var/www/index.py

I have looked at alot of posts with a similar question but none seem to work for me

i have the following /etc/apache2/httpd.conf file:

<Directory /var/www/index.py>
Options +ExecCGI
</Directory>

<Directory /var/www>
Options +ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AddHandler cgi-script .py
DirectoryIndex index.py         

</Directory>

<Directory /var/www/tiles>
  AddHandler mod_python .py
  PythonHandler TileStache::modpythonHandler
  PythonOption config /home/TileStache/tilestache.cfg
</Directory>

When i try to access the homepage as : just the host name: http://exampleHost.com i get the following error on the error log:

Options ExecCGI is off in this directory: /var/www/index.py

but when i go to http://exampleHost.com/index.py it works fine.

So Im guessing something is overriding the /var/www directory? I dont have a .htaccess file in the /var/www directory.


I had to modify the follwing file:

/etc/apache2/sites-enabled/000-default

Changed the /var/www directory to inlcude the +ExecCGI and AddHandler like so:

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

After you have enabled the cgi module with

sudo a2enmod cgi

You can go and modify the file

/etc/apache2/sites-enabled/000-default

and find the section that reads this

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin/">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
</Directory>

this tells apache that when you meet the url host e.g

localhost/cgi-bin/ 

that it should check the directory /usr/lib/cgi-bin for the file you have requested and if it finds it executes it. now you can make it execute from any directory by adding the directory inside the Directory directive e.g if you want it to be /var/www (where the cgi files are) you can have

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

with that a request to

localhost/script.cgi

should work perfectly. In addition make sure you have the

libapache2-mod-perl

package installed.