6

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.

2
  • 1
    Do you actually have a directory named index.py? Or is that a file in the /var/www directory? Are you sure you didn't mean to use a <file>, or <location> container instead? – Zoredache Jul 18 '13 at 17:28
  • its a file in /var/www My plan was to remove that part once i got the /var/www directory to work properly cause i want to hit the exampleHost.com and load the index.py file but i am getting the Options ExecCGI is off in this directory: /var/www/index.py – Joshi Jul 18 '13 at 17:45
1

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>
1

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.

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.