【发布时间】:2012-04-20 12:06:50
【问题描述】:
我在 ubuntu 服务器上配置我的 EC2 实例(亚马逊网络服务),以测试 django(python)
我已经安装了 python 和 apache 服务器,
我的 url 地址 index.html 上有 It works! [apache] 页面
现在我正在配置 wsgi 和 mod_wsgi [for python 和 django],
我按照这个信息来配置wsgi:
deploy python wsgi app tutorial
但是当我尝试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]
然后转到 mysite/application/application.wsgi
http://ec2-107-20-20-19.compute-1.amazonaws.com/cucus/application/application.wsgi
在我的浏览器中, 我看到了页面的代码,但没有看到呈现的“hello world”
我错过了什么?
我需要为 ubuntu 配置虚拟主机吗?即使我只使用一个站点?
谢谢!
【问题讨论】:
-
为什么要在浏览器中访问 wsgi 文件本身?这不是它的工作原理,否则所有 WSGI 应用程序都会在其 URL 中包含它。
-
@DanielRoseman,谢谢,这是我的问题,那么为什么这个“application.wsgi”里面有hello world的代码?,用什么url来测试这个hello world?以上代码,谢谢!
-
您似乎忽略了该教程中标题为“配置 Apache”的部分。然后转到正常的
/(root) URL。
标签: python django amazon-ec2 mod-wsgi virtual-machine