0

我正在尝试使用 mod_wsgi(在 apache 上)设置 django。它给出了这个错误:

尝试提供目录:/home/mysite/products/templates/

httpd.conf:

ServerRoot "/home/mysite"

<Location "/">
    SetHandler python-program
    SetEnv DJANGO_SETTINGS_MODULE mysite.settings
    PythonPath "['/home/','/home/mysite/'] + sys.path"
    PythonDebug Off
</Location>

django.wsgi(放在文件夹/home/mysite/public_wsgi):

import os
import sys

os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

path = '/home/mysite/'
if path not in sys.path:
    sys.path.append(path)

虚拟主机:

<VirtualHost *:80>
ServerName mysite.com
    ServerAlias www.mysite.com
DocumentRoot /home/mysite/products/templates

WSGIScriptAlias /wsgi /home/mysite/public_wsgi

Alias /static/ /home/mysite/products/static/
Alias /robots.txt /home/mysite/products/templates/robots.txt
Alias /favicon.ico /home/mysite/products/static/images/favicon.ico
<Directory /home/mysite/products/static>
    Order deny,allow
    Allow from all
</Directory>    

<Directory />
    Options FollowSymLinks
    Options Indexes
    DirectoryIndex /home/mysite/products/templates/home.html
    AllowOverride None
</Directory>

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined

</VirtualHost>

似乎无法弄清楚问题所在。我该如何解决这个错误?对此的任何帮助都会很棒。谢谢

4

2 回答 2

0

您也应该在 sys.path 中包含 /home/

于 2013-05-11T15:05:40.853 回答
0

您正在尝试同时使用 mod_python 和 mod_wsgi。这将导致各种冲突和问题。您应该删除 mod_python 设置并重新开始。

于 2013-05-11T22:20:40.693 回答