使用mod_wsgi在Apache上部署PyAMF Django项目

时间:2011-06-16 07:51:10

标签: django apache mod-wsgi pyamf

我在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)

我将不胜感激。

由于

1 个答案:

答案 0 :(得分:0)

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

NameVirtualHost *:8000

通常只有端口80的这样一条线。