在centos 5.4上使用mod_wsgi和apache设置Django的问题

时间:2010-03-11 13:34:31

标签: django apache centos mod-wsgi

我正在尝试使用mod_wsgi设置apache,通过CentOS 5.4上的nginx代理服务Django。我想首先使用Wsgi配置Apache以在本地端口上提供服务,但是当我运行curl localhost:8080时出现403错误

# Httpd config:
Listen 127.0.0.1:8080
NameVirtualHost 127.0.0.1:8080

<VirtualHost 127.0.0.1:8080>
    ServerName staging.example.com

    LogLevel warn
    ErrorLog  /home/django/project_name/log/apache_error.log
    CustomLog /home/django/project_name/log/apache_access.log combined

    DocumentRoot /home/django/project_name/django_project_dir/

    WSGIDaemonProcess staging.example.com user=apache group=apache threads=25
    WSGIProcessGroup staging.example.com
    WSGIScriptAlias / /home/django/project_name/django_project_dir/django.wsgi

    <Directory /home/django/project_name/django_project_dir>
        Order deny,allow
        Allow from all
    </Directory>

</VirtualHost>

我的wsgi脚本:

#/home/django/project_name/django_project_dir/django.wsgi
ALLDIRS = ['/home/django/project_dir/virtualenv/lib/python2.4/site-packages']

import os
import sys
import site

prev_sys_path = list(sys.path)

for directory in ALLDIRS:
    site.addsitedir(directory)

new_sys_path = []
for item in list(sys.path):
    if item not in prev_sys_path:
       new_sys_path.append(item)
       sys.path.remove(item)
sys.path[:0] = new_sys_path


sys.path.append('/home/django/project_name/')

os.environ['PYTHON_EGG_CACHE'] = '/home/django/.python-eggs'
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

此配置有什么问题?

0 个答案:

没有答案