0

64-bit Win7 Apache 2.2.19, mod_wsgi/3.4-BRANCH Python/2.7.3

No errors visible in logs:

[Wed Aug 01 17:44:48 2012] [notice] Apache/2.2.19 (Win64) mod_wsgi/3.4-BRANCH Python/2.7.3 configured -- resuming normal operations
[Wed Aug 01 17:44:48 2012] [notice] Server built: May 28 2011 15:18:56
[Wed Aug 01 17:44:48 2012] [notice] Parent: Created child process 8528
[Wed Aug 01 17:44:48 2012] [debug] mpm_winnt.c(477): Parent: Sent the scoreboard to the child
[Wed Aug 01 17:44:48 2012] [notice] Child 8528: Child process is running
[Wed Aug 01 17:44:48 2012] [debug] mpm_winnt.c(398): Child 8528: Retrieved our scoreboard from the parent.
[Wed Aug 01 17:44:48 2012] [info] Parent: Duplicating socket 556 and sending it to child process 8528
[Wed Aug 01 17:44:48 2012] [debug] mpm_winnt.c(595): Parent: Sent 1 listeners to child 8528
[Wed Aug 01 17:44:48 2012] [debug] mpm_winnt.c(554): Child 8528: retrieved 1 listeners from parent
[Wed Aug 01 17:44:48 2012] [info] mod_wsgi (pid=8528): Initializing Python.
[Wed Aug 01 17:44:48 2012] [info] mod_wsgi (pid=8528): Attach interpreter ''.
[Wed Aug 01 17:44:48 2012] [notice] Child 8528: Acquired the start mutex.
[Wed Aug 01 17:44:48 2012] [notice] Child 8528: Starting 64 worker threads.
[Wed Aug 01 17:44:48 2012] [notice] Child 8528: Starting thread to listen on port 80.

Config straight out of guides:

WSGIScriptAlias /wsgi "C:/Program Files/Apache Software Foundation/Apache2.2/wsgi/wsgi_test.py"

<Directory "C:/Program Files/Apache Software Foundation/Apache2.2/wsgi/">
    Order allow,deny
    Allow from all
</Directory>

WSGI app:

def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World from wsgi!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]

Get 403 and log message:

Options ExecCGI is off in this directory: C:/Program Files/Apache Software Foundation/Apache2.2/wsgi/wsgi_test.py

Add Options +ExecCGI to Directory (and stick "#!c:\Python27\python.exe" at top of app file) Get 500 and log message:

Premature end of script headers: wsgi_test.py

Straight python as scripting language via ExecCGI works fine, with #!... at top of script and ExecCGI config for another Directory, etc.

Implication is that WSGIScriptAlias is behaving a lot like Alias and not setting ExecCGI or invoking properly to call the application() function.

How do I debug ? Or is there something obvious missing ?

Raymond Tau
  • 682
  • 3
  • 16
rickL
  • 3
  • 1

1 Answers1

0

Your configuration isn't even being used as is picking up CGI configuration from else where in the Apache configuration.

Rename your file to wsgi_test.wsgi and change the WSGIScriptAlias directive correspondingly and it may become more obvious what the issue is. Technically the CGI definition for .py should not override WSGIScriptAlias.

Graham Dumpleton
  • 6,090
  • 2
  • 21
  • 19