title: Setting up Apache on Ubuntu LAMP Server to execute Python in Virtual Host
body: <p>I am trying to setup a LAMP server in my lab, and I'm having trouble getting Apache to execute the .py files.  It instead just downloads them.  At first I thought my header <a href="https://stackoverflow.com/questions/17329194/which-python-intrpetor-should-i-be-putting-in-py-header">might be wrong</a>, but when I changed it, it unfortunately I'm still not executing the .py.  On the plus side I can load the site, run the PHP, and CRUD the MySQL.  I think the problem might be in how I'm setting up my Virtual Host.  Here is the Apache2.conf:</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
      Alias "/SiteIwant" "/var/www/SiteIwant"
      ServerName localhost
      DocumentRoot /var/www/SiteIwant
      CustomLog /var/www/SiteIwant/my_access.log combined
      ErrorLog /var/www/SiteIwant/my_error.log
          AddType application/x-httpd-php .php
          SetEnv LD_LIBRARY_PATH /etc/init.d/mysql
      &lt;Directory /var/www/SiteIwant&gt;
          Options None ExecCGI
          AddHandler cgi-script .cgi .pl .py
          #AddHandler mod_python .py
          DirectoryIndex index.php
          AllowOverride AuthConfig
          Order deny,allow
          Deny from All
              Allow from 999.999.999.0/24 #anonymized for posting here, but working
      &lt;/Directory&gt;
  #   &lt;Directory /var/www/SiteIwant/cgi/&gt;
      #   AllowOverride All
      #   Options +ExecCGI +SymLinksIfOwnerMatch
      #   Order allow,deny
      #   Allow from all
      #&lt;/Directory&gt;
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>I've tried it with and without the specification on the cgi folder, and I've <code>chkmod +rwx *.py</code> in <code>/var/www/SiteIwant/cgi</code>.  Just for kicks (after that didn't help), I also changed the mode of the python interpreter in /usr/bin and /usr/local/bin to +rwx.</p>
  
  <p>Everything else in the apache2.conf file is as it comes out from current Ubuntu Server-LAMP option install.</p>
  
  <p>I feel very stuck and like I'm missing something stupid/small.</p>
  
  <p><strong>Edit: Should this really be asked on Server Fault?</strong></p>
  
  <p>If I put an <code>AddHandler cgi-script .cgi .pl .py</code> outside the the Virtual Host, I get a 403 permission error, despite chmod 777 the folder.</p>