2017-04-19 77 views
0

장고 웹 사이트를 Apache 2.4 서버로 Ubuntu 16.04에 업로드하고 있습니다. 내 서버가 mod_wsgi를 실행 중입니다. ImportError : django.core.wsgi라는 모듈이 없습니다. 나는 다른 많은 해결책을 통해 읽었지만, 아무 것도 작동하지 않는 것 같습니다. 내 오류는 내 Python 설치 (Python 2.7)와 관련이 있다고 생각하지만 잘 모르겠습니다. 아파치 로그에서 내 wsgi.py, 서버의 conf 및 오류 메시지는 다음과 같습니다 :Django 웹 사이트에서 서버 오류 - ImportError : django.core.wsgi라는 모듈이 없습니다.

아파치 오류 로그 :

[Thu Apr 13 15:51:06.891778 2017] [authz_core:debug] [pid 27832:tid 140404955539200] mod_authz_core.c(809): [client 134.53.122.114:63670] AH01626: authorization result of Require all granted: granted, referer: http://173.255.204.6/ 
[Thu Apr 13 15:51:06.891833 2017] [authz_core:debug] [pid 27832:tid 140404955539200] mod_authz_core.c(809): [client 134.53.122.114:63670] AH01626: authorization result of <RequireAny>: granted, referer: http://173.255.204.6/ 
[Thu Apr 13 15:51:06.891884 2017] [authz_core:debug] [pid 27832:tid 140404955539200] mod_authz_core.c(809): [client 134.53.122.114:63670] AH01626: authorization result of Require all granted: granted, referer: http://173.255.204.6/ 
[Thu Apr 13 15:51:06.891891 2017] [authz_core:debug] [pid 27832:tid 140404955539200] mod_authz_core.c(809): [client 134.53.122.114:63670] AH01626: authorization result of <RequireAny>: granted, referer: http://173.255.204.6/ 
[Thu Apr 13 15:51:06.892105 2017] [wsgi:info] [pid 27831:tid 140404925069056] [remote 134.53.122.114:11921] mod_wsgi (pid=27831, process='site', application='site.com|'): Loading WSGI script '/var/www/site/site/wsgi.py'. 
[Thu Apr 13 15:51:06.892490 2017] [wsgi:error] [pid 27831:tid 140404925069056] [remote 134.53.122.114:11921] mod_wsgi (pid=27831): Target WSGI script '/var/www/site/site/wsgi.py' cannot be loaded as Python module. 
[Thu Apr 13 15:51:06.892504 2017] [wsgi:error] [pid 27831:tid 140404925069056] [remote 134.53.122.114:11921] mod_wsgi (pid=27831): Exception occurred processing WSGI script '/var/www/site/site/wsgi.py'. 
[Thu Apr 13 15:51:06.892532 2017] [wsgi:error] [pid 27831:tid 140404925069056] [remote 134.53.122.114:11921] Traceback (most recent call last): 
[Thu Apr 13 15:51:06.892564 2017] [wsgi:error] [pid 27831:tid 140404925069056] [remote 134.53.122.114:11921] File "/var/www/site/site/wsgi.py", line 9, in <module> 
[Thu Apr 13 15:51:06.892611 2017] [wsgi:error] [pid 27831:tid 140404925069056] [remote 134.53.122.114:11921]  from django.core.wsgi import get_wsgi_application 
[Thu Apr 13 15:51:06.892647 2017] [wsgi:error] [pid 27831:tid 140404925069056] [remote 134.53.122.114:11921] ImportError: No module named django.core.wsgi 

wsgy.py :

import os, sys 

sys.path.append('/var/www/site') 

from django.core.wsgi import get_wsgi_application 

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "site.settings") 

application = get_wsgi_application() 

아파치 컨퍼런스 :

<VirtualHost *:80> 
     ServerName site.com 
     ServerAlias www.site.com 
     ServerAdmin [email protected] 
     DocumentRoot /var/www/site 

     WSGIDaemonProcess site python-path=/usr/bin/python 
     WSGIProcessGroup site 

     WSGIScriptAlias//var/www/site/site/wsgi.py process-group=site 

     <Directory /var/www/site/site> 
     <Files wsgi.py> 
     Require all granted 
     </Files> 
     </Directory> 

     Alias /media/ /var/www/site/media/ 
     Alias /static/ /var/www/site/static/ 

     <Directory /var/www/site/static> 
     Require all granted 
     </Directory> 

     <Directory /var/www/site/media> 
     Require all granted 
     </Directory> 

     ErrorLog ${APACHE_LOG_DIR}/error.log 
     CustomLog ${APACHE_LOG_DIR}/access.log combined 
</VirtualHost> 

which python을 입력하여 Python이 설치된 위치를 찾으면 결과는 012입니다.

브라우저에서 내 IP 주소를 방문하려고하면 Apache Conf에서 제공 한 관리자 이메일과 함께 500 개의 서버 오류가 발생하므로이 파일이 사용되고 있음을 알 수 있습니다.

내 Apache Conf를 통해 내 wsgi.py 파일을 사용 중지하고 내 IP 주소를 방문하면 내 /var/www/ 폴더에있는 파일을 탐색 할 수있는 웹 페이지가 있습니다.

파이썬 콘솔에서 from django.core.wsgi import get_wsgi_application을 테스트하면 정상적으로 작동합니다.

virtualenv를 사용하고 있지 않습니다.

나를 디버깅 할 수있는 다른 방법이 있습니까, 아니면 누구든지이 오류에 대한 해결책을 찾았습니까?

+0

@Thameem 난 여전히 서버 오류가 발생합니다. – Kevin

+0

WSGIDaemonProcess 사이트 파이썬 경로 =/usr/bin/python 부분을 가 대신이 WSGIDaemonProcess 사이트 파이썬 경로 =은/var/www /에서 사이트/사이트 파이썬 가정의 무언가를 시도 =/usr/bin/python 부분을 – Thameem

+0

@Thameem I 그 (것)들을 시도하고 동일한 과실을 받았다. 더 자세한 오류 메시지를 얻을 수있는 방법이 있는지 알고 계십니까? – Kevin

답변

0
당신은 아마이처럼 novabucket 모듈을 포함하는 상위 디렉토리 포함하도록의 sys.path를 설정하기 위해 wsgi.py 파일을 편집해야

:

수입 SYS sys.path.insert (0, '/home/maxmackie/webapps/django/novabucket ') 자세한 내용은 설명서에 나와 있습니다. Python 및 WSGI 스크립트 내의 sys.path에 추가

이러한 변경을 수행 한 후에는 반드시 Apache를 다시 시작하십시오. . 나는 오류 로그에서 같은 출력이 작업을 수행 할 때