2017-02-07 5 views
0

Ich habe ein Problem mit der Deployment-Django-App auf dem Apache2-Webserver. Ich hatte so einen Fehler:Apache2, Django. Importfehler

ImportError: No module named 'myproject.settings'

Aber ich wusste nicht warum. Kannst du mir helfen?

Meine Konfigurationsdatei:

<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> 

Und 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() 

Struktur des Projekts:

project 
|--ENV 
|--project 
|----project 
|------wsgi.py 
|------settings.py 
+0

Wo ist 'settings.py'? Hast du wirklich 'WSGIScriptAlias ​​//var/www/meinProjekt/meinProjekt/meinProjekt/wsgi.py'? Die Verwendung von gefälschten Namen macht das Debuggen von solchen Dingen immer schwieriger. – Alasdair

+0

Ja, hier versuchen Pfad zu ** wsgi.py ** und ** settings.py ** - **/var/www/Agora/Agora/Agora ** – AndMar

Antwort

0

Ihre Einstellungsdatei befindet sich in /var/www/agora/agora/agora/settings.py, Sie müssen also /var/www/agora/agora auf dem Python-Pfad sein.

Momentan sieht es so aus, als ob Sie stattdessen python-path=/var/www/agora im Python-Pfad haben.

Wenn Sie den Python-Pfad in der Apache-Konfiguration korrekt festlegen, müssen Sie sys.path in der Datei wsgi.py nicht ändern.

+0

Danke, es hat mir geholfen. – AndMar

0

Sie müssen dies hinzufügen:

WSGIPythonPath /var/www/myproject/myproject 
+0

Danke für die Antwort. Ich habe es versucht, aber das hat mir nicht geholfen – AndMar

Verwandte Themen