I'm very new in web servers and stuff but I have certain knowledge in Python, is it possible to use it as cgi, such as php? I know that python has a cgi module.

ps: I'm using apache2 in a debian server.

1 Answer 1


Sure, there are many ways of serving python applications via apache2.

you can use python via mod_python :

<Directory /var/www/localhost/htdocs> 
   AddHandler mod_python .py
   PythonHandler mod_python.publisher 
   PythonDebug On 

or if your app is written in any of python frameworks (flask,bottle,django), you can just configure frameworks webserver and point apache2 to it's socket/port and act as a proxy.

  • where do I put this lines?
    – Gonzo
    Aug 28, 2012 at 1:56
  • this is just an example of configuration of apache2 vhost. You should go at least through one tutorial with apache2 mod python as well as writing cgi scripts for apache with python. Simplest way to start serving python sites is to use framework like Bottle which has it's own www server and use apache2 not as a python cgi server but as a proxy.
    – wojciechz
    Aug 28, 2012 at 10:21

Not the answer you're looking for? Browse other questions tagged .