我试图通过 apache 中的 wsgi 在虚拟环境中为 django 应用程序提供服务。但我得到了错误
[Fri Oct 11 18:28:55 2013] [error] [client 86.151.x.x] ImportError: Could not import settings 'myapp.myapp_settings' (Is it on sys.path?): No module named settings
然而一切似乎都很好,
小路
/opt/django/webtools_django15/
|-- __init__.py
|-- myapp
| |-- __init__.py
| |-- __init__.pyc
| |-- myapp.wsgi
| |-- myapp_settings.py
| |-- myapp_settings.pyc
| |-- myapp_urls.py
| |-- forms.py
| |-- forms.pyc
| |-- models.py
| |-- tests.py
| |-- views.py
| |-- views.py-bak
| `-- views.pyc
|-- manage.py
|-- modules
| `-- dnslookup.py
|-- static
| !! omitted !!
|-- templates
| `-- myapp
| |-- myapp-about.html
| |-- myapp-base.html
| |-- myapp-cachecheck-result.html
| |-- myapp-glossary.html
| |-- myapp-home.html
| |-- myapp-input-cachecheck.html
| |-- myapp-input-cachecheck.html-bak
| |-- myapp-input-lookup.html
| |-- myapp-input-lookup.html-bak
| |-- myapp-input-report.html
| |-- myapp-input-report.html-bak
| |-- myapp-lookup-result.html
| |-- myapp-partners.html
| |-- myapp-ratelimited.html
| `-- myapp-report-result.html
`-- webtools_django15
|-- __init__.py
|-- __init__.pyc
|-- settings.py
|-- settings.py-bak
|-- settings.pyc
`-- urls.py
WSGI 文件
(django15)[root@bob-x django]# cat /opt/django/webtools_django15/myapp/myapp.wsgi
import os
import sys
import site
site.addsitedir("/opt/django/virtenv/django15/lib/python2.7/site-packages/")
from django.core.handlers.wsgi import WSGIHandler
sys.path.append('/opt/django/webtools_django15/')
sys.path.append('/opt/django/')
os.environ['DJANGO_SETTINGS_MODULE'] = 'myapp.myapp_settings'
application = WSGIHandler()
阿帕奇
<VirtualHost *:80 >
DocumentRoot /opt/django/webtools_django15/
ServerName myapp.co.uk
ServerAlias www.myapp.co.uk direct.myapp.co.uk
WSGIApplicationGroup myapp
WSGIScriptAlias / /opt/django/webtools_django15/myapp/myapp.wsgi
WSGIDaemonProcess myapp processes=5 python-path=/opt/django/webtools_django15:/opt/django/virtenv/django15/lib/python2.7/site-packages/ threads=1
Alias /static/ /opt/django/webtools_django15/static/
ErrorLog logs/myapp-error.log
CustomLog logs/myapp-access.log common
</VirtualHost>
我在这里错过了一些简单的东西吗?
谢谢,