【发布时间】:2012-07-22 20:05:36
【问题描述】:
最初,当我在我的 ubuntu 服务器上安装带有 wsgi 的 Django 1.3 时,我使用了包含的 setup.py 文件,因此当我想更新时,请按照安装指南的 Remove any old versions of Django 部分重命名我的站点中的“django”文件夹-packages "django.old" 然后使用 Django 1.4 的 setup.py 文件安装新版本
重新启动我的 apache 服务器后,我收到一个标准的 500 内部错误。我检查了 apache 错误日志,发现 ADMIN_MEDIA_PREFIX 已被弃用,因此在 Django 1.4 release notes 之后,我从设置文件中删除了 ADMIN_MEDIA_PREFIX,并将管理文件移动到名为“admin”的文件夹下的静态目录中,如图所示。
我再次重新启动我的 apache 服务器并收到相同的标准 500 错误,但这次我尝试在 apache 错误日志上运行 tail 时没有注册新的错误。
没有任何进一步的错误消息,我真的被卡住了,所以我们将不胜感激。
下面是我的 apache 站点配置文件和 wsgi 文件的内容
网站配置:
<VirtualHost *:80>
ServerAdmin me@mysite.com
ServerName www.mysite.com
ServerAlias mysite.com
# Indexes + Directory Root.
# DirectoryIndex index.html index.htm index.php
DocumentRoot /home/www/www.mysite.com/htdocs/
# CGI Directory
ScriptAlias /cgi-bin/ /home/www/www.mysite.com/cgi-bin/
<Location /cgi-bin>
Options +ExecCGI
</Location>
# Logfiles
ErrorLog /home/www/www.mysite.com/logs/error.log
CustomLog /home/www/www.mysite.com/logs/access.log combined
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/www/www.mysite.com/htdocs/>
Options FollowSymLinks MultiViews
AllowOverride All
allow from all
</Directory>
### Connect Django to the URL using WSGI (the django recommended method)
WSGIScriptAlias /myproject /django/myproject/django.wsgi
### Alias to the location of the static dir (images, css, js etc.)
Alias /myproject/static /django/myproject/static
<Directory /django/myproject/static>
Order deny,allow
allow from all
</Directory>
</VirtualHost>
django.wsgi:
import sys
import os
import django.core.handlers.wsgi
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
application = django.core.handlers.wsgi.WSGIHandler()
sys.path.insert(0, '/django/myproject/')
sys.path.insert(0, '/django/myproject/')
from django.core.handlers.wsgi import WSGIHandler
application = WSGIHandler()
请注意,出于安全原因,我已尝试从这些文件中删除或重命名任何识别信息,因此如果存在明显的语法错误等,可能是由于此编辑所致。这些文件的原始版本同样接受名称更改,并且在 Django 1.3 下运行良好
【问题讨论】:
-
在
settings.py中设置DEBUG=True。这有帮助吗? -
可能存在一些向后不兼容的问题。设置
DEBUG=True,可能有助于识别错误来源。 -
对不起,我忘了说我已经在我的设置中设置了 DEBUG=True。我还尝试通过“django-admin.py shell”运行一些命令来检查我可以访问 django 并连接到数据库
-
你检查过
/home/www/www.mysite.com/logs/error.log和/var/log/apache2/error.log -
一切正常,从 1.4 开始,CsrfResponseMiddleware 已被移除
标签: django django-1.3 django-1.4 django-wsgi