1
我現在面臨兩天的問題,但我無法得到任何有效的答案。
我有一個名爲「ekz」的項目叫做「welcome」,我需要使用apache + wsgi(我正在使用osx yosemite)來執行這個項目。當我使用「manage.py runserver命令」運行項目,它工作正常,但是當我運行它使用Apache它給了我錯誤「無模塊命名ekz.settings」這是來自Apache的完整的跟蹤日誌:ImportError:沒有名爲ekz.settings的模塊wsgi + apache
mod_wsgi (pid=29210): Target WSGI script '/Users/s2labs/Desktop/ekz/ekz/wsgi.py' cannot be loaded as Python module.
mod_wsgi (pid=29210): Exception occurred processing WSGI script '/Users/s2labs/Desktop/ekz/ekz/wsgi.py'.
Traceback (most recent call last):
File "/Users/s2labs/Desktop/ekz/ekz/wsgi.py", line 16, in <module>
application = get_wsgi_application()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
django.setup()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/__init__.py", line 17, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/conf/__init__.py", line 55, in __getattr__
self._setup(name)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/conf/__init__.py", line 43, in _setup
self._wrapped = Settings(settings_module)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/conf/__init__.py", line 99, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named ekz.settings
這裏是wsgi.py文件,我沒有修改它,當我使用pycharm創建的項目創建它:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ekz.settings")
application = get_wsgi_application()
這裏是configura httpd.conf文件的重刑,我跟着docs做到這一點:
Alias /static/ /Users/s2labs/Desktop/ekz/welcome/static/
<Directory /Users/s2labs/Desktop/ekz/welcome/static>
Require all granted
</Directory>
WSGIScriptAlias//Users/s2labs/Desktop/ekz/ekz/wsgi.py
WSGIPythonPath /Users/s2labs/Desktop/ekz:/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
<Directory /Users/s2labs/Desktop/ekz/ekz>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
我真的很感激任何幫助,謝謝。