Still need more feedback Re: Successful installation of mod_python on Apache on Win2k?

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

  1. Rolfe

    Rolfe Guest

    In response to Peter Maas <>:

    Thank you. I have rechecked my config (shown below) - but I still
    can't get the script (also shown below) to run in mod_python. I've
    tried it in both the /cgi-bin/, and in /htdocs/test/:

    THE CONFIG FILE READS AS FOLLOWS:

    # MOD_PYTHON STUFF (added by
    Rolfe)--------------------------------ROLFE
    LoadModule python_module modules/mod_python.so

    <Directory "C:/Program Files/Apache Group/Apache2/cgi-bin/">
    AddHandler python-program .py
    PythonHandler mod_python.publisher
    PythonHandler mptest
    PythonHandler form
    PythonDebug On
    </Directory>

    <Directory "C:/Program Files/Apache Group/Apache2/htdocs/test/">
    AddHandler python-program .py
    PythonHandler mod_python.publisher
    PythonHandler mptest
    PythonHandler form
    PythonDebug On
    </Directory>

    THE FULL SCRIPT READS AS FOLLOWS:

    from mod_python import apache

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

    Adding:
    #! c:/python22/python.exe to the top of the script brings up a
    DOWNLOAD FILE dialog. In that dialog, if I select RUN, the script
    executes quickly in a DOS-like command line window and then exits.

    Any suggestions?
     
    Rolfe, Sep 26, 2003
    #1
    1. Advertising

  2. Rolfe

    Peter Otten Guest

    Rolfe wrote:

    > Thank you. I have rechecked my config (shown below) - but I still
    > can't get the script (also shown below) to run in mod_python. I've
    > tried it in both the /cgi-bin/, and in /htdocs/test/:


    (just guessing)

    1 The LoadModule path looks suspicous, on windows I would expect
    mod_python.dll rather than mod_python.so

    2 Did you restart the apache after changing the config file?

    Peter
     
    Peter Otten, Sep 26, 2003
    #2
    1. Advertising

  3. Rolfe

    Rolfe Guest

    > 1 The LoadModule path looks suspicous, on windows I would expect
    > mod_python.dll rather than mod_python.so
    >
    > 2 Did you restart the apache after changing the config file?
    >
    > Peter


    Hi Peter, I checked C:\Program Files\Apache Group\Apache2\modules and
    found mod_python.so there, so the LoadModule path was okay. When I
    made a plain vanilla default RE-INSTALLATION of Apache and mod_python
    (see instructions below) everything worked fine. I think I goofed
    something up in the previous installation file.


    RUNNING MOD_PYTHON/APACHE/WINDOWS2000

    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 29, 2003
    #3
    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. walala
    Replies:
    4
    Views:
    2,175
    Ralf Hildebrandt
    Sep 8, 2003
  2. Replies:
    1
    Views:
    565
    Peter Blum
    Jun 14, 2005
  3. Rolfe
    Replies:
    2
    Views:
    368
    Rolfe
    Sep 26, 2003
  4. Piet
    Replies:
    6
    Views:
    1,230
    David Fraser
    Sep 2, 2004
  5. Andrea Fiore

    Mod_python installation: apache Warning

    Andrea Fiore, Mar 16, 2005, in forum: Python
    Replies:
    0
    Views:
    383
    Andrea Fiore
    Mar 16, 2005
Loading...

Share This Page