I ran into a problem with one of my python scripts the other day and noticed from the Apache logs that it was causing a segfault somewhere. This is the first time I have had to deal with a segfault in a web based application so I looked around for a debugging solution. I found that mod_python has has a flag that will trigger Apache to start a console running PDB. In order to get this working, “PythonEnablePdb On” needs to be added to the Apache config for the site running the Mod_python script and Apache needs to be ran with the following command.

apache2ctl -DONE_PROCESS