2015-01-26 203 views
1

我想在一臺服務器上部署多個Django項目。 它是Windows 32位Xampp。 mod_wsgi是32位。 python是32位。 Django是1.7.3版本。在一個Xampp Windows Apache Mod_WSGI服務器上部署兩個Django項目

我讀過很多帖子,並嘗試了很多東西,但我無法克服這個問題。

瀏覽器中顯示的以下錯誤還表示某些版本信息。

Server error! 
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script. 
Error 500 
localhost Apache/2.4.4 (Win32) OpenSSL/0.9.8y PHP/5.4.19 mod_wsgi/3.5 Python/2.7.6 

我可以用這種方法成功部署一個django應用程序。如果我只部署一個,例如: c:/ p2/xampp/htdocs/django/mysite

當我添加第二個項目時,出現以下錯誤,只有第一個項目有效。

我在apache error.log中出現以下錯誤。

mod_wsgi (pid=11184): Exception occurred processing WSGI script 'C:/p2/xampp/htdocs/django/apache/django161c.wsgi'. 
~~~~~ some lines removed ~~~~~~ 
ImportError: Could not import settings 'mysite.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named mysite.settings 

我的httpd.conf中的最後兩行:

LoadModule wsgi_module modules/mod_wsgi.so 
Include C:/p2/xampp/htdocs/django/apache/wsgi3.conf 

我wsgi3.conf

############ 
listen 8986 
<VirtualHost *:8986> 
Alias /static/ c:/p2/xampp/htdocs/django/mysite/static/ 
WSGIScriptAlias/"c:/p2/xampp/htdocs/django/apache/mysite.wsgi" 
    DocumentRoot "c:/p2/xampp/htdocs/django/mysite" 
    ServerName 127.0.0.1 
<Directory "c:/p2/xampp/htdocs/django/apache"> 
    Allow from all 
</Directory> 
</VirtualHost> 
############ 
listen 8985 
<VirtualHost *:8985> 
WSGIScriptAlias/"c:/p2/xampp/htdocs/django/apache/django161c.wsgi" 
    DocumentRoot "c:/p2/xampp/htdocs/django/django161c" 
    ServerName 127.0.0.1 
<Directory "c:/p2/xampp/htdocs/django/apache"> 
    Allow from all 
</Directory> 
</VirtualHost> 

我mysite.wsgi:

import os, sys 
sys.path.append('c:/p2/xampp/htdocs/django/mysite') 
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' 
# works: https://www.pythonanywhere.com/forums/topic/1629/ # this is for changes to django 1.7 # 2015-01-23_Fri_14.13-PM 
from django.core.wsgi import get_wsgi_application 
application = get_wsgi_application() 

我django161c.wsgi

import os, sys 
sys.path.append('c:/p2/xampp/htdocs/django/django161c') 
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' 
from django.core.wsgi import get_wsgi_application 
application = get_wsgi_application() 

你能幫助我嗎?

回答

1

解決的辦法是:

裏有django161c.wsgi兩個 'mysite.settings' 它應該是 'django161c.settings'。

這固定了它。

然後它一直要求我在每個項目中重複登錄。

我加入

SESSION_COOKIE_PATH = 「/ django161c」

settings.py使每個站點不共享相同的會話ID的Cookie。

我爲'mysite'項目做了同樣的事情。

SESSION_COOKIE_PATH = 「/ mysite的」

另外,我匹配編譯器和mod_wsgi的

我使用的版本 蟒2.7.9阿帕奇2.4所有32位和所有VC9編譯 的mod_wsgi的是從這個帖子下載:

https://groups.google.com/forum/#!topic/modwsgi/SxedM5UKvic

我叫模塊mod_wsgi-442-ap24-w32-vc9-py279.so

這樣,我知道這是mod_wsgi的4.4.2,所有的編譯VC9,爲Apache 2.4,Python的2.7.9,所有Win32的。

相關問題