[英]configure wsgi python
im configuring my EC2 instance (amazon web services) on an ubuntu server, to test django(python)我在 ubuntu 服务器上配置我的 EC2 实例(亚马逊 web 服务),以测试 django(python)
I have python installed, and the apache server,我安装了 python 和 apache 服务器,
I have the It works!
我有It works!
[apache] page on my url address, index.html [apache]页面在我的url地址,index.html
now im configuring the wsgi and mod_wsgi [for python and django],现在我正在配置 wsgi 和 mod_wsgi [for python and django],
im following this info to configure wsgi:我正在按照此信息配置 wsgi:
deploy python wsgi app tutorial 部署 python wsgi 应用教程
but when I try the Basic Hello World WSGI Configuration
但是当我尝试Basic Hello World WSGI Configuration
时
import os
import sys
sys.path.append('/srv/www/cucus/application')
os.environ['PYTHON_EGG_CACHE'] = '/srv/www/cucus/.python-egg'
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]
and go to mysite/application/application.wsgi和 go 到 mysite/application/application.wsgi
http://ec2-107-20-20-19.compute-1.amazonaws.com/cucus/application/application.wsgi http://ec2-107-20-20-19.compute-1.amazonaws.com/cucus/application/application.wsgi
in my browser, i see the code for the page, but not the rendered "hello world"在我的浏览器中,我看到了页面的代码,但看不到呈现的“hello world”
what im i missing?我错过了什么?
do I need to configure the virtual hosts for ubuntu?, even im using just one site?我是否需要为 ubuntu 配置虚拟主机?即使我只使用一个站点?
thanks!谢谢!
You need your output to be binary.你需要你的 output 是二进制的。
Change改变
output = 'Hello World!'
to到
output = b'Hello World!'
Here's some simple WSGI boilerplate code I created - show's you how to manage a GET and POST request.这是我创建的一些简单的 WSGI 样板代码 - 向您展示如何管理 GET 和 POST 请求。
https://github.com/blarking94/Python/blob/master/web_server_gateway_interface.py https://github.com/blarking94/Python/blob/master/web_server_gateway_interface.py
Have you read any of the actual mod_wsgi documentation or watch the presentation about it:您是否阅读过任何实际的 mod_wsgi 文档或观看过有关它的演示:
http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide http://code.google.com/p/modwsgi/wiki/WhereToGetHelp?tm=6#Conference_Presentations http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide http://code.google.com/p/modwsgi/wiki/WhereToGetHelp?tm=6#Conference_Presentations
You either never set up WSGIScriptAlias or didn't enable the site for Apache properly to read it or didn't restart Apache.您要么从未设置 WSGIScriptAlias,要么没有为 Apache 正确启用站点以读取它,或者没有重新启动 Apache。
Try restarting Apache if that does not work then double your apache config you are enabling mod_wsgi with this line of code LoadModule wsgi_module modules/mod_wsgi.so
as well as WSGIScriptAlias / /path/to/mysite/apache/django.wsgi
尝试重新启动 Apache 如果这不起作用然后将您的 apache 配置加倍 您正在使用这行代码启用 mod_wsgi LoadModule wsgi_module modules/mod_wsgi.so
以及WSGIScriptAlias / /path/to/mysite/apache/django.wsgi
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.