我刚刚在dreamhost上部署了我的应用程序,它在上传文件时停止了工作。乘客只会产生500内部错误。它适用于我的开发设置。
我的乘客档案如下:
import sys, os
sys.path.append(os.getcwd())
sys.path.append(os.path.join(os.getcwd(), '/photosoc'))
os.environ['DJANGO_SETTINGS_MODULE'] = "photosoc.settings"
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
我收到标准404错误(仍启用调试)。我不得不改变我的网址文件:
from django.conf.urls.defaults import patterns, include, url
from competition.models import Image
from competition import *
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.conf import settings
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
admin.site.register(Image)
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'photosoc.views.home', name='home'),
# url(r'^photosoc/', include('photosoc.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
# url(r'^image/$', 'competition.views.index'),
url(r'^image/uploadImage', 'competition.views.uploadImage'),
url(r'^image/uploadCompleted', 'competition.views.uploadCompleted'),
url(r'^image/uploadFailed', 'competition.views.uploadFailed'),
)
urlpatterns += patterns('',
(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}))
以下内容:
from django.conf.urls.defaults import patterns, include, url
from competition.models import Image
from competition import *
from django.contrib import admin
from django.conf import settings
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
admin.site.register(Image)
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'photosoc.views.home', name='home'),
# url(r'^photosoc/', include('photosoc.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
# url(r'^image/$', 'competition.views.index'),
url(r'^image/uploadImage', 'competition.views.uploadImage'),
url(r'^image/uploadCompleted', 'competition.views.uploadCompleted'),
url(r'^image/uploadFailed', 'competition.views.uploadFailed'),
)
这是我从开发到生产切换应用程序的唯一变化。那么还有什么可能出错?
答案 0 :(得分:0)
您可能有权限问题。
好像你正在写图像文件。运行Django的进程是否有权写入文件?当您使用./manage.py运行Django时,runserver Django将获得从命令行运行的用户的权限,但在典型的生产环境中,您将使用Apache用户的权限运行。此用户可能没有写入这些图像文件的权限。您可以尝试暂时将写入目录硬编码到/ tmp,看看是否会产生影响。
当然,你真的需要看到500错误堆栈跟踪才能知道发生了什么。
答案 1 :(得分:0)
您导入的中间件类中的设置是否完全相同?仔细检查这些是否相同。
相关:
ModSecurity: Output filter: Failed to read bucket (rc 104): Connection reset by peer