Question

This question has been retitled/retagged so that others may more easily find the solution to this problem.


I am in the process of trying to migrate a project from the Django development server to a Apache/mod-wsgi environment. If you had asked me yesterday I would have said the transition was going very smoothly. My site is up, accessible, fast, etc. However, a portion of the site relies on file uploads and with this I am experiencing the strangest and most maddening issue. The particular page in question uses swfupload to POST a file and associated metadata to a url which catches the file and initiates some server-side processing. This works perfectly on the development server, but whenever I POST to this url on Apache the Django request object comes up empty--no GET, POST, or FILES data.

I have eliminated client-side issues by snooping with Wireshark. As far as I can discern the root cause stems from some sort of Apache configuration issue, possibly related to the temporary file directory I am trying to access. I am a relative newcomer to Apache configuration and have been banging my head against this for hours.

My Apache config:

<VirtualHost *:80>
ServerAdmin user@sitename.com
ServerName  sitename.com
ServerAlias www.sitename.com
LogLevel warn
WSGIDaemonProcess sitename processes=2 maximum-requests=500 threads=1
WSGIProcessGroup sitename
WSGIScriptAlias / /home/user/src/sitename/apache/django.wsgi
Alias /static /home/user/src/sitename/static
Alias /media /usr/share/python-support/python-django/django/contrib/admin/media
</VirtualHost>

My intuition is that this may have something to do with the permissions of the file upload directory I have specified in my Django settings.py ('/home/sk/src/sitename/uploads/'), however my Apache error log doesn't suggest anything of the sort, even with the log level bumped up to debug.

Suggestions on how I should go about debugging this?

Was it helpful?

Solution

Another possibility is a bug in "old" releases of mod_wsgi (I got crazy to find, and fix, it). More info in this bug report. I fixed it (for curl uploads) thanks to the following hint (that works on the CLI too, using the -H switch).

OTHER TIPS

Normally apache runs as a user "www-data"; and you could have problems if it doesn't have read/write access. However, your setup doesn't seem to use apache to access the '/home/sk/src/sitename/uploads'; my understanding from this config file is unless it hit /static or /media, apache will hand it off WGSI, so it might be good to check out those permissions and logs, rather than the apache ones.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top