我在Apache2 web服務器上部署Django應用程序時遇到了一些問題。我有這樣的錯誤:Apache2,Django。導入錯誤
ImportError: No module named 'myproject.settings'
但我不知道爲什麼。你可以幫幫我嗎?
我的配置文件:
<VirtualHost *:80>
Alias /static /var/www/myproject/myproject/static
<Directory /var/www/myproject/myproject/static>
Require all granted
</Directory>
<Directory /var/www/myproject/myproject/myproject>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess myproject python-path=/var/www/myproject python-home=/var/www/agora/ENV
WSGIProcessGroup myproject
WSGIScriptAlias//var/www/myproject/myproject/myproject/wsgi.py
</VirtualHost>
而且wsgi.py:
import os
import sys
path = '/var/www/myproject'
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
項目的結構:
project
|--ENV
|--project
|----project
|------wsgi.py
|------settings.py
'settings.py'在哪裏?你真的有'WSGIScriptAlias// var/www/myproject/myproject/myproject/wsgi.py'嗎?使用虛假名稱總是會使調試更加困難。 – Alasdair
是的,在這裏嘗試路徑** wsgi.py **和** settings.py ** - **/var/www/agora/agora/agora ** – AndMar