Problem configuring apache to run python cgi on Ubuntu 14.04

sohcahtoa82 at sohcahtoa82 at
Mon Sep 21 21:19:43 CEST 2015

On Monday, September 21, 2015 at 11:41:54 AM UTC-7, tropical... at wrote:
> Hello everybody,
> I installed the LAMP stack on in Ubuntu, but I am having
> problems configuring Apache to run python CGI scripts.
> I ran:
> sudo a2enmod cgi
> I added to apache2.conf
> <Directory /srv/www/yoursite/public_html>
>         Options +ExecCGI
>         AddHandler cgi-script .py
> </Directory>
> I created
> #!/usr/bin/env python
> # -*- coding: UTF-8 -*-# enable debugging
> import cgitb
> cgitb.enable()    
> print("Content-Type: text/html;charset=utf-8")
> print("Hello World!")
> But it is still not working.
> Can anybody help me out?
> Thanks in advance.

"It isn't working" is about as useful as telling a mechanic "My car doesn't work" without giving details on what exactly is happening.

What exactly isn't working?  What error message are you getting?

The first thing I would check is to make sure the permissions on are set to allow execution.  It is easy to forget to do that.

More information about the Python-list mailing list