【发布时间】:2012-05-26 16:18:24
【问题描述】:
我正在尝试通过 wsgi 配置 apache 和 django。但是我在导入设置方面遇到了错误,例如:
ImportError: Could not import settings 'mymask.settings' (Is it on sys.path?): No module named mymask.settings
布局
我的网站和我的应用位于以下结构中:
[root@Fileserver opt]# tree django/mysite2/
django/mysite2/
|-- 1
|-- README
|-- TEMPLATES
| |-- contact_form.html
| |-- timedate.html
| |-- whatmask_input.html
| |-- whatmask_input.html.bak
| |-- whatmask_output.html
| `-- whois_output.html
|-- __init__.py
|-- __init__.pyc
|-- apache
| `-- django.wsgi
|-- manage.py
|-- mymask
| |-- __init__.py
| |-- __init__.pyc
| |-- models.py
| |-- models.pyc
| |-- tests.py
| |-- views.py
| `-- views.pyc
|-- settings.py
|-- settings.pyc
|-- static
| |-- css
| |-- images
| `-- js
| `-- jquery.js
|-- timedate
| |-- __init__.py
| |-- __init__.pyc
| |-- models.py
| |-- tests.py
| |-- views.py
| `-- views.pyc
|-- urls.py
`-- urls.pyc
apache/django.wsgi
import os, sys
path = '/opt/django/mysite2/mymask'
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'mymask.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
httpd.conf
# Django
Alias /media/ /opt/django/mysite2/media
<Directory /opt/django/mysite2/media>
Order deny,allow
Allow from all
</Directory>
WSGIScriptAlias / /opt/django/mysite2/apache/django.wsgi
<Directory /opt/django/mysite2/apache>
Order deny,allow
Allow from all
</Directory>
WSGIScriptAlias / /opt/django/mysite2/apache/django.wsgi
有什么想法吗??
【问题讨论】:
标签: django apache django-wsgi