【发布时间】:2011-06-16 07:51:09
【问题描述】:
我在 Mac OS X 10.6 机器上安装了 PyAMF、Django、Apache2 和 mod_wsgi。在开发项目时,我使用了 Django 开发服务器。我想继续使用 http://localhost:8000/gateway 或 http://127.0.0.1:8000/gateway 作为 PyAMF 网关。我在http://localhost 上部署了我的 Flex 项目,http://localhost/phpmyadmin.They 上的 phpMyAdmin 似乎工作正常,但我无法连接到 PyAMF 网关。
这是我的 Apache 设置:
<VirtualHost *:8000>
# Set this to 'warn' when you're done with debugging
LogLevel debug
CustomLog /var/log/apache2/pyamf-access.log combined
ErrorLog /var/log/apache2/pyamf-error.log
# PyAMF remoting gateway
WSGIScriptAlias /gateway /Library/WebServer/Documents/MyApp/django.wsgi
<Directory /Library/WebServer/Documents/MyApp>
WSGIApplicationGroup %{GLOBAL}
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
这里是django.wsgi脚本的内容
import os
import sys
path = '/Library/WebServer/Documents'
if path not in sys.path:
sys.path.append(path)
sys.path.append('/Library/WebServer/Documents/MyApp')
os.environ['PYTHON_EGG_CACHE'] = '/tmp'
os.environ['DJANGO_SETTINGS_MODULE'] = 'MyApp.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
import posixpath
def application(environ, start_response):
# Wrapper to set SCRIPT_NAME to actual mount point.
environ['SCRIPT_NAME'] = posixpath.dirname(environ['SCRIPT_NAME'])
if environ['SCRIPT_NAME'] == '/':
environ['SCRIPT_NAME'] = ''
return _application(environ, start_response)
我将不胜感激。
谢谢
【问题讨论】:
-
定义“无法连接”。究竟会发生什么?您的其他应用程序之一是否响应?你有错误吗?
-
localhost:80 上的 php 应用程序正常工作。但是,当我连接到 localhost:8000 时,出现错误“无法解析 localhost:8000:未知主机。我尝试删除
块并尝试了 'WSGIScriptAlias /gateway /Library/WebServer/Documents/MyApp/hello.py '。这似乎工作正常。 -
您在哪里看到错误“无法解析 localhost:8000: 未知主机”?
标签: django apache mod-wsgi pyamf