【发布时间】:2015-03-25 09:04:17
【问题描述】:
我想在一台服务器上部署多个 Django 项目。 它是 Windows 32 位 Xampp。 mod_wsgi 是 32 位的。 python是32位的。 Django 版本为 1.7.3。
我已经阅读了很多帖子并尝试了很多东西,但我无法解决这个问题。
浏览器中显示的以下错误也表明了一些版本信息。
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
My 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()
你能帮帮我吗?
【问题讨论】:
标签: python django windows apache mod-wsgi