han*_*sen 7 python mod-wsgi wsgi python-2.7
我正在尝试使用WSGI为Apache上的特定目录设置Python,但是我收到以下错误:
mod_wsgi (pid=3857): Target WSGI script '/var/www/test/test.py' does not contain WSGI application 'application'.
Run Code Online (Sandbox Code Playgroud)
我的test.py包含:
print 'Hello, World!'
Run Code Online (Sandbox Code Playgroud)
我的wsgi.conf包含:
LoadModule wsgi_module modules/mod_wsgi.so
WSGIPythonHome /usr/local/bin/python2.7
Alias /test/ /var/www/test/test.py
<Directory /var/www/test>
SetHandler wsgi-script
Options ExecCGI
Order deny,allow
Allow from all
</Directory>
Run Code Online (Sandbox Code Playgroud)
最重要的是,有趣的是,Web浏览器返回"404 Not Found"错误,但幸运的是error_log更具启发性.
我究竟做错了什么?
Jon*_*nts 12
您正在使用WSGI,就像它是CGI一样(奇怪的是没有标题).
您需要做的是,针对您的直接问题,请参考http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide中的以下内容
def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
Run Code Online (Sandbox Code Playgroud)
所以你有application礼物.
并从参考文档.
请注意,mod_wsgi要求将WSGI应用程序入口点称为"应用程序".如果您想将其称为其他内容,则需要明确配置mod_wsgi以使用其他名称.因此,不要随意更改函数的名称.如果这样做,即使您正确设置了其他所有内容,也无法找到该应用程序.
| 归档时间: |
|
| 查看次数: |
6504 次 |
| 最近记录: |