2015-04-04 199 views
0

Django WSGI Script Won't load due to a Python issue的Django +阿帕奇+ mod_wsgi的cuasing 500內部服務器錯誤(日誌附後)

研究了一天之後,還是沒能解決的問題。 服務器聯機,在使用virtulenv 的Windows 8-64bit,python34,WAMP服務器Apache的64位

裏面的conf使用網站:

Listen 8080 
NameVirtualHost 127.0.0.1:8080 
<VirtualHost *:8080> 
ServerAdmin [email protected] 
ServerName 192.168.0.101:8080 
DocumentRoot "C:/wamp/www/venv/testweb10/testweb10" 
</VirtualHost> 

WSGIScriptAlias/"C:/wamp/www/venv/testweb10/testweb10/wsgi.py" 
WSGIPythonPath "C:/wamp/www/venv/Lib/site-packages" 

<Directory "C:/wamp/www/venv/testweb10"> 
     <Files wsgi.py> 
      Order deny,allow 
      Require all granted 
     </Files> 
</Directory> 

Settings.py

DEBUG = True 

ALLOWED_HOSTS = ['testweb10'] 

hosts

127.0.0.1  testweb10 

我懷疑,如果蟒蛇兼容性問題

用戶變量路徑:

​​

enter image description here

請幫助

+0

mod_wsgi嘗試解析您的wsgi.py腳本,但失敗。該文件的內容是什麼? – SaeX 2015-04-04 12:08:52

+0

進口OS 從django.core.wsgi進口get_wsgi_application os.environ.setdefault( 「DJANGO_SETTINGS_MODULE」, 「testweb10.settings」) 應用= get_wsgi_application() – 2015-04-04 12:13:20

+0

感謝Saex,你提醒我。 – 2015-04-04 12:22:28

回答

4

你有你的WSGI到您的virtualenv的參考。 PY?這裏是我在Linux上使用的模板,例如:

import site 
site.addsitedir('/home/mysite/venv/lib/python2.7/site-packages') 
import os 
import sys 
sys.path.append('/home/mysite/mysite') 
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' 

import django.core.handlers.wsgi 

application = django.core.handlers.wsgi.WSGIHandler() 

這是Django 1.6 btw。 Django的1.7已在wsgi.py

一些差異Django的1.7的最後兩行是:

from django.core.wsgi import get_wsgi_application 
application = get_wsgi_application() 
+0

除此之外,請確保你使用適當的安裝程序來安裝'mod_wsgi'。在安裝了Python 2&3的標準系統中,'pip install mod_wsgi'將爲Python 2.x執行安裝,而'pip3 install mod_wsgi'將爲3.x執行相同的操作。 – Jason 2015-04-04 12:40:13

+0

pip installable mod_wsgi不支持視窗。對於Windows用戶需要使用特殊的預編譯構建,除非他們想從源代碼自己編譯。請參閱https://github.com/GrahamDumpleton/mod_wsgi/blob/develop/win32/README.rst – 2015-04-04 20:43:24

0

WSGIPythonPath必須包括項目的根。

Used to specify additional directories to search for Python modules. If multiple directories are specified they should be separated by a ':' if using a UNIX like system, or ';' if using Windows.

WSGIPythonPath = "C:/wamp/www/venv/testweb10/testweb10;C:/wamp/www/venv/Lib/site-packages" 
+0

使用Windows有點不同 – 2015-04-04 13:39:46

0

最終以下似乎Django的工作1.8

import site 

site.addsitedir( 「C:/ Python34 /庫/站點包」)

import os 
import sys 
sys.path.append("C:/wamp/www/venv/testweb10/testweb10") 

from django.core.wsgi import get_wsgi_application 

os.environ["DJANGO_SETTINGS_MODULE"] = "testweb10.settings" 

application = get_wsgi_application() 

但現在得到錯誤:( [mpm_winnt:notice] [pid 3788:tid 688] AH00455:Apache/2.4.9(Win64)mod_wsgi/4.4.10 Python/3.4.3 PHP/5.5.12 co nfigured - 恢復正常操作

0

對於有同樣的問題傢伙:

的幾點建議(也爲自己):

每個組件的版本是很重要的

1)安裝Appache或Wamp服務器的清潔方式。 Makesure刪除舊的註冊表。

2)獲取Mod_WSGI並按照安裝說明仔細閱讀!

2.5)測試的mod_wsgi若無的Django

3工作正常)的最後一步是安裝Python,Django中,和設置環境和CONF。

4)測試和部署

相關問題