To run Python scripts as Apache CGI scripts you have to install and activate the apache cgi module (Ubuntu 12.04):
$> sudo apt-get install python #if not already installed $> sudo a2enmod cgid #sudo a2enmod cgi in earlier Ubuntu versions
And you have to add the following directive to your Apache configuration file:
... <Directory /var/www/sheldonroot/cgi-bin> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Require all granted AddHandler cgi-script .py DirectoryIndex index.py </Directory> ...
After that you should restart the Apache:
$> sudo service apache2 restart
That’s it! Have fun and do magic stoff 😀