Running mod_python on Apache on Windows2000 *

Discussion in 'Python' started by Rolfe, Sep 30, 2003.

  1. Rolfe

    Rolfe Guest

    Hi, I struggled, and got mod_python running on Apache/Win2k. Follow
    these instructions verbatim and you shouldn't have any trouble. These
    instructions are based on
    "http://www.modpython.org/live/current/doc-html/inst-testing.html".
    I've added specific information such as Windows filepaths and
    filenames so there's no ambiguity on what you should do. I encourage
    you to copy and paste to avoid typing errors.
    Cheers,

    Rolfe

    INSTALLING MOD_PYTHON

    1. Make a default installations of the latest/best version of Apache.

    2. Make a default installation of the latest/best version of
    mod_python.

    3. Open C:\Program Files\Apache Group\Apache2\conf\httpd.conf in
    Notepad.

    4. In httpd.conf, just below the line "#LoadModule ssl_module
    modules/mod_ssl.so", copy and paste the following section:

    #Start of section pasted in by YOURNAMEGOESHERE

    LoadModule python_module modules/mod_python.so

    <Directory "C:\Program Files\Apache Group\Apache2\htdocs/test/">

    AddHandler python-program .py
    PythonHandler mptest
    PythonDebug On

    </Directory>
    <Directory "C:\Program Files\Apache Group\Apache2\cgi-bin/">

    AddHandler python-program .py
    PythonHandler mptest
    PythonDebug On

    </Directory>
    #End of section pasted in by YOURNAMEGOESHERE

    (NOTE: Don't mess around with the other configuration settings in
    httpd.conf, - leave good enough alone. Don't worry about the
    forward/backward slashes either - it doesn't matter.)

    5. Save and close httpd.conf and wait a few seconds.

    6. Restart Apache by clicking the Apache monitor icon in your systray
    and selecting Apache2=>Restart.

    PROCEDURE COMPLETED

    ##### TESTING MOD_PYTHON #######

    1. Create a directory called "test" in htdocs so you end up with
    "C:\Program Files\Apache Group\Apache2\htdocs\test"

    2. Create a text file called mptest.py in "C:\Program Files\Apache
    Group\Apache2\htdocs\test"

    3. Paste the following text into mptest.py:

    from mod_python import apache

    def handler(req):

    req.write("Hello World!")
    return apache.OK

    4. Save and close mptest.py.
    5. In your file browser, copy and paste mptest from "C:\Program
    Files\Apache Group\Apache2\htdocs\test" to "C:\Program Files\Apache
    Group\Apache2\cgi-bin".

    6. Assuming your sitting at the same machine that's running Apache,
    enter the URL "http://localhost/test/mptest.py" in your web browser.
    The browser displays "Hello World!" and nothing else. This confirms
    that Apache can run cgi scripts in the /test/ directory.

    7. Repeat step 6 using the URL "http://localhost/cgi-bin/mptest.py"
    instead. The browser displays "Hello World!" and nothing else. This
    confirms that Apache can run cgi scripts in the /cgi-bin/ directory.

    PROCEDURE COMPLETED - mod_python works!

    ######## NOTES ######### Remove either of the following sections (from
    <Directory to </Directory>) in order to disable cgi scripts in a
    particular directory. I understand it is very poor security to run cgi
    scripts under htdocs, so I'd try getting rid of that one first.

    <Directory "C:\Program Files\Apache Group\Apache2\htdocs/test/">

    AddHandler python-program .py
    PythonHandler mptest
    PythonDebug On

    </Directory>
    <Directory "C:\Program Files\Apache Group\Apache2\cgi-bin/">

    AddHandler python-program .py
    PythonHandler mptest
    PythonDebug On

    </Directory>
    ######### ACKNOWLEDGEMENTS ########## Thank you, Steve Holden, for
    your guidance. I'm very much looking forward to your book, Python Web
    Programming.

    Thank you Peter Maas for your response on comp.lang.python
     
    Rolfe, Sep 30, 2003
    #1
    1. Advertising

  2. Rolfe

    M-a-S Guest

    Any success with Apache/2.0.47 (Win32) + Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on win32 ?
    M-a-S


    "Rolfe" <> wrote in message news:...
    > Hi, I struggled, and got mod_python running on Apache/Win2k. Follow
    > these instructions verbatim and you shouldn't have any trouble. These
    > instructions are based on
    > "http://www.modpython.org/live/current/doc-html/inst-testing.html".
    > I've added specific information such as Windows filepaths and
    > filenames so there's no ambiguity on what you should do. I encourage
    > you to copy and paste to avoid typing errors.
    > Cheers,
    >
    > Rolfe
    >
    > <...>
     
    M-a-S, Oct 3, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Raghunath
    Replies:
    0
    Views:
    490
    Raghunath
    Sep 15, 2003
  2. Elizabeth Harmon

    Windows2000,Word2003,ASP.Net - Help

    Elizabeth Harmon, Nov 30, 2003, in forum: ASP .Net
    Replies:
    10
    Views:
    580
    Elizabeth Harmon
    Dec 1, 2003
  3. Henning Krause [MVP]
    Replies:
    0
    Views:
    357
    Henning Krause [MVP]
    May 25, 2005
  4. neha
    Replies:
    1
    Views:
    523
    Brad Teale
    Oct 19, 2005
  5. blbmdsmith
    Replies:
    1
    Views:
    661
    Graham Dumpleton
    Dec 14, 2006
Loading...

Share This Page