Run Python on Apache CGI

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


After that you should restart the Apache:

$> sudo service apache2 restart

That’s it! Have fun and do magic stoff 😀

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.