【问题标题】:django deployment issue with mod_wsgimod_wsgi 的 django 部署问题
【发布时间】:2009-08-20 07:18:53
【问题描述】:

我正在尝试部署位于 home/doga/headend/ 的 django 项目,并且只是在 localhost 上运行它(将是一个 LAN 可访问的项目)。我的主要问题是我可以很好地使用该网站,但是 /admin/ 文件夹给了我Internal Server Error 错误。

这里是我的 etc/apache2/sites-available/default 文件

<VirtualHost *:80>
ServerName /
ServerAlias  */
DocumentRoot /home/doga/headend/
LogLevel warn
WSGIScriptAlias / /home/doga/headend/apache/django.wsgi
Alias /media /home/doga/headend/media/statics
Alias /admin_media /usr/lib/python2.4/site-packages/django/contrib/admin/media

</VirtualHost>

这是我的 home/doga/headend/apache/django.wsgi 文件

import os, sys
import django.core.handlers.wsgi


sys.path.append('/home/doga/')
sys.path.append('/home/doga/headend')

os.environ['DJANGO_SETTINGS_MODULE'] = 'headend.settings'
application = django.core.handlers.wsgi.WSGIHandler()

最后是我的主要 url.py

from django.conf.urls.defaults import *
from django.conf import settings

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Example:
    # (r'^headend/', include('headend.foo.urls')),

    # Uncomment the admin/doc line below and add 'django.contrib.admindocs' 
    # to INSTALLED_APPS to enable admin documentation:
    (r'^table/(?P<pid>.*)/$', 'main.views.table_view'),
    (r'^graph/(?P<pid>.*)/$', 'main.views.graph_view'),
    (r'^graph/$', 'main.views.platform_graph_view'),
    (r'^table/$', 'main.views.platform_view'),
    (r'^csv/$', 'main.views.csv_view'),
    (r'^recent/$', 'main.views.recent_view'),
    (r'^$', 'main.views.main_view'),
    (r'^cs/(?P<number>.*)/$', 'main.views.ch_view'),
    #(r'^admin/doc/', include('django.contrib.admindocs.urls')),
    # Uncomment the next line to enable the admin:
    (r'^admin/', include(admin.site.urls)),
    #(r'^$', 'main.views.main_view'),
    #(r'^media/(?P<path>.*)$', 'django.views.static.serve',
    #   {'document_root': '/home/uluc/headendmedia/statics'}),
)

【问题讨论】:

  • 您用于 ServerName 和 ServerAlias 指令的值是错误的,尽管如果这是唯一的 VirtualHost,这本身不会导致问题,因为 Apache 无论如何都会默认使用它。无论哪种方式,您仍然应该修复它。正如其他人所说,您不应该将 DocumentRoot 设置为您的 Django 站点所在的位置。从 Apache 错误日志中查看实际消息也很重要,这样可以查看是什么导致了该错误。

标签: django deployment mod-wsgi


【解决方案1】:

我认为您不应该将DocumentRoot 设置为/home/doga/headend。这不会让您访问所有源代码吗?

Apache 日志为内部服务器错误提供了哪些详细信息?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-07-14
    • 1970-01-01
    • 1970-01-01
    • 2012-01-15
    • 2011-05-26
    • 2011-02-05
    • 2011-03-19
    • 1970-01-01
    相关资源
    最近更新 更多