SearchWiki:
  5 User(s) Active on Site
  232 Wiki Pages

Most Recently Modified

Meeting Schedules

Club Resources (edit)

How This Wiki Works

Meeting space complements of:
Computer books
            and technical books at discount prices
Check them out; they are a great source of technical books at very good prices!

If you have shopped at Nerdbooks.com, help them out by reviewing them at ResellerRatings.com. You will need your invoice number to prove you are a real customer, and not just ballot stuffing.
Recent Changes Printable View Page History Edit Page
Content Last Modified on June 11, 2006, at 06:40 PM CST

Installing Mod Python

Here are some notes about installing mod_python.

Check that the version of python is current (2.4.x) or, if you have multiple versions available make sure that you know where to find the latest version.

Make sure you know which version of apache you are using and get the appropriate mod_python to match: Apache 1.3.x works with mod_python 2.7.x Apache 2.x works with mod_python 3.x

I installed 2.7.11 from a tarball using the ./configure routine without problems and then used httpd -S to check the config files before restarting Apache. This worked ok - it complained about PythonHandler?. Better to find out early rather than after stopping Apache right?

Modified and checked the config file (httpd.conf) several times before removing the IfDefine? HAVE_PYTHON from the conf file. Success! Ordered a restart on Apache with apachectl then looked at the output of phpinfo to verify that mod_python was present with the correct version of python. So far so good.

Following the example at modpython.com in the testing section of the documentation, I added a Directory section to my httpd.conf.. but I placed it in a separate file called python.conf and used an Include directiv e to make sure it gets used. Better to have changes like this in a separate file where I can tweak a lot without affecting the main (and stable) httpd.conf.

The Directory section tells Apache to process .py files with a PythonHandler? but the syntax varies accordng to which version of Apache you are using so I won't include it here.

I created a /trial directory (to match the config changes to Apache) and added a short script called mptest.py which I lifted directly from modpython documentation:

    from mod_python import apache

    def handler(req):
        req.send_http_header()
        req.write("Hello World!")
        return apache.OK

and then tried loading the page in a browser. Visiting the URL /trial/mptest.py worked! But (and here's what took the next hour), visiting /trial/mptest did not work.. I was offered dialog box to decide what to do with the cgi script until I made this change:

    from mod_python import apache

    def handler(req):
        req.content_type='text/plain'
        req.send_http_header()
        req.write("Hello World!")
        return apache.OK

So now, I can visit /trial/mptest or /trial/mptest.py and get the same result. The part I have not figured out is this: If I need the content-type header to make it work in the second case (without the .py suffix), then why does it work in the first case (with the .py suffix)?

More adventures in mod_python later..

Recent Changes Printable View Page History Edit Page