Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mod_wsgi, mod_python, or just cgi?

I've been playing around with my own webserver (Apache+Ubuntu) and python. From what I've seen there are 3(?) main ways of doing this:

  1. Apache configured to handle .py as cgi
  2. Apache configured to use mod_python that is now outdated(?)
  3. Apache configured to use mod_wsgi

I recall reading that Django prefers mod_wsgi, and I'm kinda interested in learning Django (I've heard their official tutorial is rather excellent).

What is the 'recommended' setup? I presume there's really no reason to use mod_python anymore, but what are the differences between handling .py as cgi, and mod_wsgi? Is it possible to run them in tandem (and would you want to?), or is that just a ridiculous idea and I should stop thinking such crazy things?

I guess really I'm just looking for a primer on Apache+Python (links are also good) - nothing I've come across so far has been terribly informative - they were mainly just how-to's.

like image 587
Wayne Werner Avatar asked Jul 23 '10 15:07

Wayne Werner


People also ask

What is Mod_python WSGI?

mod_wsgi is an Apache HTTP Server module by Graham Dumpleton that provides a WSGI compliant interface for hosting Python based web applications under Apache. As of version 4.5.

What is CGI and WSGI?

The WSGI application runs on the server, and acts as the interface between the server and web application written in a python. The CGI application runs on the server and processes requests passed by server.

What is Apache WSGI?

mod_wsgi is an Apache HTTP Server module that embeds a Python application within the server and allow them to communicate through the Python WSGI interface as defined in the Python PEP 333. WSGI is one of the Python ways to produce high quality and high performance web applications.


2 Answers

mod_python is dead, so using mod_python probably isn't a good idea for new projects. Personally, I prefer to use mod_wsgi over CGI (or FastCGI). It's dead-simple to set up, and much more efficient.

like image 79
mipadi Avatar answered Oct 04 '22 03:10

mipadi


  1. Don't use CGI. It's inefficient. Spawning a new process for each request. No thanks

  2. Dont't spend much time with mod_python

  3. Use mod_wsgi.

If you want to write CGI-like stuff without a framework, use mod_wsgi anyway. The WSGI standard (PEP 333) is essential for creating web applications in an easy, interchangeable, reusable, plug-and-playable way.

like image 31
S.Lott Avatar answered Oct 04 '22 04:10

S.Lott