title: Python CGI executable script downloads / shows script code
body: <p>A script I wrote long ago (getWords.py) used to be executable at my localhost (<a href="http://local.example.com/getWords.py?query-string" rel="nofollow">http://local.example.com/getWords.py?query-string</a>)</p>
  
  <p>My python script starts like this :</p>
  
  <pre><code>#!/usr/bin/env python
  # chmod 755 getWords.py
  
  print "Content-type: text/html\n\n"
  
  import os, sys, time, cgi, cgitb, re
  import json, hashlib, gzip, urllib, urllib2
  cgitb.enable()
  </code></pre>
  
  <p>I have enabled ExecCGI</p>
  
  <p>cat /etc/apache2/sites-available/example</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
      ServerName local.example.com
      DocumentRoot /home/username/Dropbox/vhosts/example/
      &lt;Directory /home/username/Dropbox/vhosts/example&gt;
          Options +Indexes +FollowSymLinks +MultiViews +ExecCGI
          AllowOverride All
          Order allow,deny
          allow from all
      &lt;/Directory&gt;
      ErrorLog /var/log/apache2/error.example.log
      LogLevel warn
      CustomLog /var/log/apache2/access.example.log combined
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>But still the script force downloads (FireFox) or shows the script code (Chrome).</p>
  
  <p><code>-rwxr-xr-x  1 username username  4794 Jul 14 17:15 getWords.py</code></p>
  
  <p>Any idea what is wrong on my localhost ? </p>
  
  <pre><code>$ apache2 -v
  Server version: Apache/2.4.12 (Ubuntu)
  Server built:   Feb  4 2015 14:21:10
  $ python -V
  Python 2.7.3
  </code></pre>
  
  <p>On my host (Webfaction), its running at <a href="http://example.com/getWords.py?query-string" rel="nofollow">http://example.com/getWords.py?query-string</a></p>