[mod_python] Compiling mod_python

Graham Dumpleton graham.dumpleton at gmail.com
Tue Mar 20 05:27:45 EST 2007


On 20/03/07, Roberto C. Sánchez <roberto at connexer.com> wrote:
> On Tue, Mar 20, 2007 at 09:35:14AM +0100, Gabriele Farina wrote:
> > Hi,
> >
> > today I'm trying to compile mod_python on a Debian Linux box.
> > I installed correctly apache 2.2.4 and Python 2.5 from sources and
> > then tried to compile mod_python. I get this error:
> >
> Umm, why on Earth would you install Apache *and* Python from sources on
> Debian?  Just use aptitude.  Besides, mod_python is also packaged for
> Debian.

One reason for recompiling Python is because the prepackaged binary
distributions of Python are generally never built with the
--enabled-shared option. This means you only have a static libpython.a
file and on 64 bit platforms when recompiling mod_python like above
this presents problems sometimes as Python packages are only built as
32 bit binaries. Also, that there is only a static libpython.a and not
a libpython.so means that the static Python library has to be embedded
within the mod_python.so file to work. This means that instead of your
mod_python.so being in the order of a few hundred KBytes it is over
1MB in size. Because the Python library part of this is not
relocatable object files, when it gets loaded into memory it
potentially has to have address relocations done on it resulting in
the mod_python.so no longer being shared between processes and instead
each of your Apache child processes ends up with up to 1.5MB of extra
private memory in use. In the end your Python web application is going
to probably take a lot more memory than that but it doesn't make the
situation any better.

Thus, to the OP, rebuild your Python installation from source first
and ensure that --enable-shared is used when configure is run. After
you have that reinstalled, then try rebuilding mod_python and see if
the error goes away. To save trashing the existing Python installation
you might install new version of Python elsewhere. Be warned that you
may have to ensure location of  'python' executable for new version is
in PATH before standard one for user that Apache runs as. See how it
goes without doing that first though. Not sure if rebuilding Apache is
actually necessary.

Graham



More information about the Mod_python mailing list