0

I've just deployed my application on dreamhost and it's stopped working when uploading files. Passenger just produces a 500 internal error. It works on my development set up.
My passenger file looks like:

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()

I get the standard 404 error(debug is still enabled). I have had to change my urls file though from:

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}))

To the following:

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'),
)

This is the only change I've made to the application from the switch from development to production. So what else could have gone wrong?

Dean
  • 8,668
  • 17
  • 57
  • 86
  • on dreamhost do you have access to your web servers logs? if it's producing a 500 then the error should be loggged somewhere? – dm03514 Jan 25 '12 at 12:49
  • You should try get access to the server logs so that you can read the stack trace (and post it here). It'll give you a much better idea of what the problem might be – Timmy O'Mahony Jan 25 '12 at 12:49
  • if you don't have access to the logs you should set up the admin email address in your settings. Then when you're NOT in debug mode, the app should email you the error stack. You should do this anyway. – GivP Jan 25 '12 at 12:51

2 Answers2

0

You may have a permission problem.

It seems like you are writing image files. Does the process that is running Django have permission to write files? When you are running Django locally with ./manage.py runserver Django will get the permissions of the user that runs from the command line, but in a typical production environment you'd be running with the permissions of the Apache user. This user may not have permission to write those image files. You could try temporarily hardcoding the write directory to /tmp to see if that makes a difference.

Of course, you will really need see that 500 error stack trace to know what's going on.

Mark Chackerian
  • 21,866
  • 6
  • 108
  • 99
0

Are your settings exactly the same in what middleware classes your importing? Double check that these are the same.

Related:

ModSecurity: Output filter: Failed to read bucket (rc 104): Connection reset by peer

Community
  • 1
  • 1
Dean
  • 8,668
  • 17
  • 57
  • 86