【问题标题】:Deploying PyAMF Django project on Apache with mod_wsgi使用 mod_wsgi 在 Apache 上部署 PyAMF Django 项目
【发布时间】:2011-06-16 07:51:09
【问题描述】:

我在 Mac OS X 10.6 机器上安装了 PyAMF、Django、Apache2 和 mod_wsgi。在开发项目时,我使用了 Django 开发服务器。我想继续使用 http://localhost:8000/gatewayhttp://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


【解决方案1】:

当您在端口 8000 上添加单独的 VirtualHost 时,您是否也在适当的位置添加到 Apache 配置:

NameVirtualHost *:8000

通常只有 80 端口会有这样的一行。

【讨论】:

  • 我添加了 NameVirtualHost 配置,但仍然出现同样的错误。
  • 我能够通过将虚拟主机块移动到 httpd-vhosts.conf 成功部署 Django
猜你喜欢
  • 2012-12-19
  • 1970-01-01
  • 2017-12-13
  • 1970-01-01
  • 1970-01-01
  • 2012-12-20
  • 2011-07-14
  • 2012-06-17
  • 2017-01-30
相关资源
最近更新 更多